Class: Bcome::Ssh::Command
- Inherits:
-
Object
- Object
- Bcome::Ssh::Command
- Defined in:
- lib/objects/ssh/command.rb
Instance Attribute Summary collapse
-
#exit_code ⇒ Object
Returns the value of attribute exit_code.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #exit_signal(data) ⇒ Object
-
#initialize(params) ⇒ Command
constructor
A new instance of Command.
- #is_success? ⇒ Boolean
- #output ⇒ Object
- #success_codes ⇒ Object
- #unset_node ⇒ Object
Constructor Details
#initialize(params) ⇒ Command
Returns a new instance of Command.
7 8 9 10 11 12 13 |
# File 'lib/objects/ssh/command.rb', line 7 def initialize(params) @raw = params[:raw] @node = params[:node] @exit_code = nil @exit_signal = nil @stdin = ''; @stdout = ''; @stderr = '' end |
Instance Attribute Details
#exit_code ⇒ Object
Returns the value of attribute exit_code.
5 6 7 |
# File 'lib/objects/ssh/command.rb', line 5 def exit_code @exit_code end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
5 6 7 |
# File 'lib/objects/ssh/command.rb', line 5 def node @node end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/objects/ssh/command.rb', line 5 def raw @raw end |
#stderr ⇒ Object
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/objects/ssh/command.rb', line 5 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
5 6 7 |
# File 'lib/objects/ssh/command.rb', line 5 def stdout @stdout end |
Instance Method Details
#exit_signal(data) ⇒ Object
43 44 45 |
# File 'lib/objects/ssh/command.rb', line 43 def exit_signal(data) @exit_signal = data end |
#is_success? ⇒ Boolean
29 30 31 |
# File 'lib/objects/ssh/command.rb', line 29 def is_success? exit_code.to_i == 0 end |
#output ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/objects/ssh/command.rb', line 19 def output cmd_output = @stdout cmd_output += "\nExit code:" + "\s#{@exit_code}" cmd_output += "\nSTDERR: #{@stderr}" if exit_code == 1 && !@stderr.empty? "\n#{cmd_output}" end |
#success_codes ⇒ Object
33 34 35 |
# File 'lib/objects/ssh/command.rb', line 33 def success_codes ['0'] end |
#unset_node ⇒ Object
15 16 17 |
# File 'lib/objects/ssh/command.rb', line 15 def unset_node @node = nil end |