Class: Cmds::Result
- Inherits:
-
Object
- Object
- Cmds::Result
- Defined in:
- lib/cmds/result.rb
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#assert ⇒ Object
raises an error if there was one returns the Result so that it can be chained.
- #error? ⇒ Boolean
-
#initialize(cmd, status, out, err) ⇒ Result
constructor
A new instance of Result.
- #ok? ⇒ Boolean
Constructor Details
#initialize(cmd, status, out, err) ⇒ Result
Returns a new instance of Result.
5 6 7 8 9 10 |
# File 'lib/cmds/result.rb', line 5 def initialize cmd, status, out, err @cmd = cmd @status = status @out = out @err = err end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
3 4 5 |
# File 'lib/cmds/result.rb', line 3 def cmd @cmd end |
#err ⇒ Object (readonly)
Returns the value of attribute err.
3 4 5 |
# File 'lib/cmds/result.rb', line 3 def err @err end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
3 4 5 |
# File 'lib/cmds/result.rb', line 3 def out @out end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
3 4 5 |
# File 'lib/cmds/result.rb', line 3 def status @status end |
Instance Method Details
#assert ⇒ Object
raises an error if there was one returns the Result so that it can be chained
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/cmds/result.rb', line 22 def assert if error? msg = NRSER.squish " command `\#{ @cmd }` exited with status \#{ @status }\n and stderr \#{ err.inspect }\n BLOCK\n\n raise SystemCallError.new msg, @status\n end\n self\nend\n" |
#error? ⇒ Boolean
16 17 18 |
# File 'lib/cmds/result.rb', line 16 def error? ! ok? end |
#ok? ⇒ Boolean
12 13 14 |
# File 'lib/cmds/result.rb', line 12 def ok? @status == 0 end |