Class: Jiveapps::Shell
- Inherits:
-
String
- Object
- String
- Jiveapps::Shell
- Defined in:
- lib/jiveapps/shell.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
Instance Method Summary collapse
- #command ⇒ Object
- #error? ⇒ Boolean
-
#initialize(command) ⇒ Shell
constructor
A new instance of Shell.
- #out? ⇒ Boolean
- #run ⇒ Object
Constructor Details
#initialize(command) ⇒ Shell
Returns a new instance of Shell.
11 12 13 |
# File 'lib/jiveapps/shell.rb', line 11 def initialize(command) @command = command end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
7 8 9 |
# File 'lib/jiveapps/shell.rb', line 7 def error @error end |
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
9 10 11 |
# File 'lib/jiveapps/shell.rb', line 9 def exit_status @exit_status end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
8 9 10 |
# File 'lib/jiveapps/shell.rb', line 8 def out @out end |
Instance Method Details
#command ⇒ Object
32 33 34 |
# File 'lib/jiveapps/shell.rb', line 32 def command @command.join(' ') end |
#error? ⇒ Boolean
36 37 38 |
# File 'lib/jiveapps/shell.rb', line 36 def error? @exit_status != 0 end |
#out? ⇒ Boolean
40 41 42 |
# File 'lib/jiveapps/shell.rb', line 40 def out? !!@out end |
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/jiveapps/shell.rb', line 15 def run out = err = nil begin status, out, err = systemu(@command) rescue => e puts e.inspect end @exit_status = status.exitstatus replace @error = err unless err.empty? replace @out = out unless out.empty? self end |