Class: FastForward::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/fastforward/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Builder

Returns a new instance of Builder.

Yields:

  • (_self)

Yield Parameters:



3
4
5
6
7
8
9
# File 'lib/fastforward/builder.rb', line 3

def initialize
  @global_options = []
  @inputs         = []
  @outputs        = []

  yield(self) if block_given?
end

Instance Method Details

#commandObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fastforward/builder.rb', line 19

def command
  cmd = Sh::Cmd.new("ffmpeg") do |c|
    @inputs.each do |input|
      input.options.each do |option|
        c.opt(option.name).arg(option.value)
      end
      c.opt("-i").arg(input.filename)
    end

    @outputs.each do |output|
      output.options.each do |option|
        c.opt(option.name).arg(option.value)
      end
      c.arg(output.filename)
    end
  end
end

#input(filename, &block) ⇒ Object



11
12
13
# File 'lib/fastforward/builder.rb', line 11

def input(filename, &block)
  @inputs.push Input.new(filename, &block)
end

#output(filename, &block) ⇒ Object



15
16
17
# File 'lib/fastforward/builder.rb', line 15

def output(filename, &block)
  @outputs.push Output.new(filename, &block)
end

#to_sObject



37
38
39
# File 'lib/fastforward/builder.rb', line 37

def to_s
  command.to_s
end