Class: Bcome::Ssh::Command
- Inherits:
-
Object
- Object
- Bcome::Ssh::Command
- Defined in:
- lib/objects/ssh/command.rb
Instance Attribute Summary collapse
-
#bootstrap ⇒ Object
Returns the value of attribute bootstrap.
-
#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
- #pretty_result ⇒ Object
- #success_codes ⇒ Object
- #unset_node ⇒ Object
Constructor Details
#initialize(params) ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 10 11 |
# File 'lib/objects/ssh/command.rb', line 5 def initialize(params) @raw = params[:raw] @node = params[:node] @exit_code = nil @exit_signal = nil @stdin = ''; @stdout = ''; @stderr = '' end |
Instance Attribute Details
#bootstrap ⇒ Object
Returns the value of attribute bootstrap.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def bootstrap @bootstrap end |
#exit_code ⇒ Object
Returns the value of attribute exit_code.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def exit_code @exit_code end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def node @node end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def raw @raw end |
#stderr ⇒ Object
Returns the value of attribute stderr.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def stderr @stderr end |
#stdout ⇒ Object
Returns the value of attribute stdout.
3 4 5 |
# File 'lib/objects/ssh/command.rb', line 3 def stdout @stdout end |
Instance Method Details
#exit_signal(data) ⇒ Object
42 43 44 |
# File 'lib/objects/ssh/command.rb', line 42 def exit_signal(data) @exit_signal = data end |
#is_success? ⇒ Boolean
28 29 30 |
# File 'lib/objects/ssh/command.rb', line 28 def is_success? exit_code.to_i == 0 end |
#output ⇒ Object
23 24 25 26 |
# File 'lib/objects/ssh/command.rb', line 23 def output command_output = is_success? ? @stdout : "Exit code: #{@exit_code}\n\nSTDERR: #{@stderr}" "\n#{command_output}" end |
#pretty_result ⇒ Object
17 18 19 |
# File 'lib/objects/ssh/command.rb', line 17 def pretty_result is_success? ? 'success'.success : 'failure'.error end |
#success_codes ⇒ Object
32 33 34 |
# File 'lib/objects/ssh/command.rb', line 32 def success_codes ['0'] end |
#unset_node ⇒ Object
13 14 15 |
# File 'lib/objects/ssh/command.rb', line 13 def unset_node @node = nil end |