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.
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.
6 7 8 |
# File 'lib/executor.rb', line 6 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 |
Instance Method Details
#execute ⇒ Object
10 11 12 13 14 15 |
# File 'lib/executor.rb', line 10 def execute @output, status = Open3.capture2e(@command) @exit_code = status.exitstatus success? end |
#success? ⇒ Boolean
17 18 19 |
# File 'lib/executor.rb', line 17 def success? @exit_code.nil? ? true : @exit_code.zero? end |