Class: VideoTranscoding::Tool
- Inherits:
-
Object
- Object
- VideoTranscoding::Tool
- Defined in:
- lib/video_transcoding/tool.rb
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Class Method Summary collapse
- .properties(command_name) ⇒ Object
- .provide(command_name, test_args, &test_block) ⇒ Object
- .use(command_name) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
9 10 11 |
# File 'lib/video_transcoding/tool.rb', line 9 def properties @properties end |
Class Method Details
.properties(command_name) ⇒ Object
22 23 24 25 26 |
# File 'lib/video_transcoding/tool.rb', line 22 def self.properties(command_name) fail "#{command_name} not provided" unless @@tools.has_key? command_name @@tools[command_name].prepare @@tools[command_name].properties end |
.provide(command_name, test_args, &test_block) ⇒ Object
11 12 13 14 |
# File 'lib/video_transcoding/tool.rb', line 11 def self.provide(command_name, test_args, &test_block) fail "#{command_name} already provided" if @@tools.has_key? command_name @@tools[command_name] = Tool.new(command_name, test_args, &test_block) end |
.use(command_name) ⇒ Object
16 17 18 19 20 |
# File 'lib/video_transcoding/tool.rb', line 16 def self.use(command_name) fail "#{command_name} not provided" unless @@tools.has_key? command_name @@tools[command_name].prepare command_name end |
Instance Method Details
#prepare ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/video_transcoding/tool.rb', line 28 def prepare return if @ready output = '' begin IO.popen([@command_name] + @test_args, :err=>[:child, :out]) { |io| output = io.read } rescue Errno::ENOENT raise "#{@command_name} not available" end @test_block.call output, $CHILD_STATUS.exitstatus, @properties @ready = true end |