Class: PopCap::Commander
- Inherits:
-
Object
- Object
- PopCap::Commander
- Defined in:
- lib/pop_cap/ffmpeg/commander.rb
Overview
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Instance Method Summary collapse
-
#execute ⇒ Object
Public: Execute the command using Open3.capture3.
-
#initialize(*args) ⇒ Commander
constructor
Public: Initialize.
-
#stderr ⇒ Object
Public: Open3.capture3 returns an array of three elements.
-
#stdout ⇒ Object
Public: Open3.capture3 returns an array of three elements.
-
#success? ⇒ Boolean
Public: Open3.capture3 returns an array of three elements.
Constructor Details
#initialize(*args) ⇒ Commander
Public: Initialize
args - Arguments should be escaped with an interpolated literal.
18 19 20 21 22 23 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 18 def initialize(*args) raise(ArgumentError, ) if args.empty? @args = args @command = shell_escaped_arguments @executed = [] end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
13 14 15 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 13 def command @command end |
Instance Method Details
#execute ⇒ Object
Public: Execute the command using Open3.capture3. It will return an instance of Commander, in order to chain methods.
29 30 31 32 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 29 def execute @executed = Open3.capture3(*command) self end |
#stderr ⇒ Object
Public: Open3.capture3 returns an array of three elements. The second element returned is stderr.
44 45 46 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 44 def stderr @executed[1] end |
#stdout ⇒ Object
Public: Open3.capture3 returns an array of three elements. The first element returned is stdout.
37 38 39 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 37 def stdout @executed[0] end |
#success? ⇒ Boolean
Public: Open3.capture3 returns an array of three elements. The third element returned is status. Status can have a ‘success?’ of true or false.
Examples
self.success?
# => true
57 58 59 |
# File 'lib/pop_cap/ffmpeg/commander.rb', line 57 def success? @executed[2].success? end |