Class: TapDance::ShellResult
- Inherits:
-
Object
- Object
- TapDance::ShellResult
- Defined in:
- lib/tap_dance/shell_result.rb
Instance Attribute Summary collapse
-
#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.
Class Method Summary collapse
Instance Method Summary collapse
- #error? ⇒ Boolean
-
#initialize(out, err = nil, status = 0) ⇒ ShellResult
constructor
A new instance of ShellResult.
- #okay? ⇒ Boolean
- #stderr? ⇒ Boolean
- #stdout? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(out, err = nil, status = 0) ⇒ ShellResult
Returns a new instance of ShellResult.
35 36 37 38 39 |
# File 'lib/tap_dance/shell_result.rb', line 35 def initialize(out, err=nil, status=0) @out = out.to_s @err = err.to_s @status = status end |
Instance Attribute Details
#err ⇒ Object (readonly)
Returns the value of attribute err.
22 23 24 |
# File 'lib/tap_dance/shell_result.rb', line 22 def err @err end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
21 22 23 |
# File 'lib/tap_dance/shell_result.rb', line 21 def out @out end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
23 24 25 |
# File 'lib/tap_dance/shell_result.rb', line 23 def status @status end |
Class Method Details
.of(cmd) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/tap_dance/shell_result.rb', line 25 def self.of(cmd) out = nil err = nil sts = open4(cmd) do |pid, stdin, stdout, stderr| out = stdout.read err = stderr.read end new out, err, sts.exitstatus end |
Instance Method Details
#error? ⇒ Boolean
45 46 47 |
# File 'lib/tap_dance/shell_result.rb', line 45 def error? @status != 0 || erred(@out) || erred(@err) end |
#okay? ⇒ Boolean
41 42 43 |
# File 'lib/tap_dance/shell_result.rb', line 41 def okay? !error? end |
#stderr? ⇒ Boolean
53 54 55 |
# File 'lib/tap_dance/shell_result.rb', line 53 def stderr? @err.strip != "" end |
#stdout? ⇒ Boolean
49 50 51 |
# File 'lib/tap_dance/shell_result.rb', line 49 def stdout? @out.strip != "" end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/tap_dance/shell_result.rb', line 57 def to_s if @out.strip == "" then @err else @out end end |