Class: Executor
- Inherits:
-
Object
- Object
- Executor
- Defined in:
- lib/executor.rb
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(command) ⇒ Executor
constructor
A new instance of Executor.
- #success? ⇒ Boolean
Constructor Details
#initialize(command) ⇒ Executor
Returns a new instance of Executor.
15 16 17 |
# File 'lib/executor.rb', line 15 def initialize(command) @command = command end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
4 5 6 |
# File 'lib/executor.rb', line 4 def exit_code @exit_code end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
4 5 6 |
# File 'lib/executor.rb', line 4 def output @output end |
Class Method Details
.execute(command) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/executor.rb', line 7 def execute(command) @output, status = Open3.capture2e(command) @exit_code = status.exitstatus [@output, @exit_code] end |
Instance Method Details
#execute ⇒ Object
19 20 21 22 23 24 |
# File 'lib/executor.rb', line 19 def execute @output, status = Open3.capture2e(@command) @exit_code = status.exitstatus success? end |
#success? ⇒ Boolean
26 27 28 |
# File 'lib/executor.rb', line 26 def success? @exit_code.nil? ? true : @exit_code.zero? end |