Class: Media::Input

Inherits:
Object
  • Object
show all
Defined in:
lib/media/input.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, &block) ⇒ Input

Returns a new instance of Input.



7
8
9
10
11
12
# File 'lib/media/input.rb', line 7

def initialize(args, &block)
  @url     = args.fetch(:url) { raise ':url required'}
  @options = Array args.fetch(:options, [])
  
  block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given?
end

Instance Method Details

#graph(&block) ⇒ Object Also known as: graph=



25
26
27
28
29
# File 'lib/media/input.rb', line 25

def graph(&block)
  return @graph unless block_given?
  
  @graph = Option.new(key: 'filter_complex', value: Filter::Graph.new(&block))
end

#options(value = nil) ⇒ Object Also known as: options=



18
19
20
21
22
# File 'lib/media/input.rb', line 18

def options(value=nil)
  return @options unless value
    
  @options = value.map {|k,v| Option.new(key: k, value: v)}
end

#to_aObject



14
15
16
# File 'lib/media/input.rb', line 14

def to_a
  (options << graph << url).compact.map(&:to_a)
end