Class: Clinode::Command::Shell
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#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.
71 72 73 |
# File 'lib/clinode/command.rb', line 71 def initialize(*command) @command = command end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
68 69 70 |
# File 'lib/clinode/command.rb', line 68 def error @error end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
69 70 71 |
# File 'lib/clinode/command.rb', line 69 def out @out end |
Instance Method Details
#command ⇒ Object
90 91 92 |
# File 'lib/clinode/command.rb', line 90 def command @command.join(' ') end |
#error? ⇒ Boolean
94 95 96 |
# File 'lib/clinode/command.rb', line 94 def error? !!@error end |
#out? ⇒ Boolean
98 99 100 |
# File 'lib/clinode/command.rb', line 98 def out? !!@out end |
#run ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/clinode/command.rb', line 75 def run Clinode.debug "sh: #{command}" out = err = nil Open3.popen3(*@command) do |_, pout, perr| out = pout.read.strip err = perr.read.strip end replace @error = err unless err.empty? replace @out = out unless out.empty? self end |