Class: Media::Command::Converter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Converter

Returns a new instance of Converter.



9
10
11
12
13
14
15
16
# File 'lib/media/command/converter.rb', line 9

def initialize(args={})
  @options = Array args.fetch(:options, [])
  @inputs  = Array args.fetch(:inputs, [])
  @outputs = Array args.fetch(:outputs, [])
  
  @cmd      = args.fetch(:cmd, 'ffmpeg')
  @subshell = args.fetch(:subshell, Subshell)
end

Instance Attribute Details

#inputsObject

Returns the value of attribute inputs.



7
8
9
# File 'lib/media/command/converter.rb', line 7

def inputs
  @inputs
end

#optionsObject

Returns the value of attribute options.



7
8
9
# File 'lib/media/command/converter.rb', line 7

def options
  @options
end

#outputsObject

Returns the value of attribute outputs.



7
8
9
# File 'lib/media/command/converter.rb', line 7

def outputs
  @outputs
end

Instance Method Details

#callObject



18
19
20
# File 'lib/media/command/converter.rb', line 18

def call
  @subshell.new(cmd: to_s).call
end

#to_sObject



22
23
24
# File 'lib/media/command/converter.rb', line 22

def to_s
  [@cmd, options, inputs, outputs].reject(&:empty?).join(' ')
end