Class: RubyCode::CommandResult
- Inherits:
-
Object
- Object
- RubyCode::CommandResult
- Defined in:
- lib/rubycode/value_objects.rb
Overview
Represents the result of a bash command execution
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
readonly
Returns the value of attribute exit_code.
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(stdout:, stderr: "", exit_code: 0) ⇒ CommandResult
constructor
A new instance of CommandResult.
- #output ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(stdout:, stderr: "", exit_code: 0) ⇒ CommandResult
Returns a new instance of CommandResult.
81 82 83 84 85 |
# File 'lib/rubycode/value_objects.rb', line 81 def initialize(stdout:, stderr: "", exit_code: 0) @stdout = stdout @stderr = stderr @exit_code = exit_code end |
Instance Attribute Details
#exit_code ⇒ Object (readonly)
Returns the value of attribute exit_code.
79 80 81 |
# File 'lib/rubycode/value_objects.rb', line 79 def exit_code @exit_code end |
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
79 80 81 |
# File 'lib/rubycode/value_objects.rb', line 79 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
79 80 81 |
# File 'lib/rubycode/value_objects.rb', line 79 def stdout @stdout end |
Instance Method Details
#==(other) ⇒ Object
99 100 101 102 103 104 |
# File 'lib/rubycode/value_objects.rb', line 99 def ==(other) other.is_a?(CommandResult) && stdout == other.stdout && stderr == other.stderr && exit_code == other.exit_code end |
#output ⇒ Object
91 92 93 |
# File 'lib/rubycode/value_objects.rb', line 91 def output success? ? stdout : stderr end |
#success? ⇒ Boolean
87 88 89 |
# File 'lib/rubycode/value_objects.rb', line 87 def success? exit_code.zero? end |
#to_s ⇒ Object
95 96 97 |
# File 'lib/rubycode/value_objects.rb', line 95 def to_s output end |