Class: Net::SSH::SessionCommand
- Inherits:
-
Object
- Object
- Net::SSH::SessionCommand
- Defined in:
- lib/net/ssh/session_command.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#exit_code ⇒ Object
Returns the value of attribute exit_code.
-
#finish_time ⇒ Object
Returns the value of attribute finish_time.
-
#output ⇒ Object
Returns the value of attribute output.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#failure? ⇒ Boolean
(also: #error?)
Check if exit code is not successful.
-
#initialize(command, output = nil, exit_code = nil, duration = 0) ⇒ SessionCommand
constructor
Initialize a new session command.
-
#success? ⇒ Boolean
Check if exit code is successful.
-
#to_s ⇒ String
Get command string representation.
Constructor Details
#initialize(command, output = nil, exit_code = nil, duration = 0) ⇒ SessionCommand
Initialize a new session command
14 15 16 17 18 19 |
# File 'lib/net/ssh/session_command.rb', line 14 def initialize(command, output=nil, exit_code=nil, duration=0) @command = command @output = output || '' @exit_code = Integer(exit_code) rescue 1 if exit_code != nil @duration = Float(duration) end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/net/ssh/session_command.rb', line 4 def command @command end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
4 5 6 |
# File 'lib/net/ssh/session_command.rb', line 4 def duration @duration end |
#exit_code ⇒ Object
Returns the value of attribute exit_code.
5 6 7 |
# File 'lib/net/ssh/session_command.rb', line 5 def exit_code @exit_code end |
#finish_time ⇒ Object
Returns the value of attribute finish_time.
6 7 8 |
# File 'lib/net/ssh/session_command.rb', line 6 def finish_time @finish_time end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/net/ssh/session_command.rb', line 5 def output @output end |
#start_time ⇒ Object
Returns the value of attribute start_time.
6 7 8 |
# File 'lib/net/ssh/session_command.rb', line 6 def start_time @start_time end |
Instance Method Details
#failure? ⇒ Boolean Also known as: error?
Check if exit code is not successful
29 30 31 |
# File 'lib/net/ssh/session_command.rb', line 29 def failure? exit_code != 0 end |
#success? ⇒ Boolean
Check if exit code is successful
23 24 25 |
# File 'lib/net/ssh/session_command.rb', line 23 def success? exit_code == 0 end |
#to_s ⇒ String
Get command string representation
37 38 39 |
# File 'lib/net/ssh/session_command.rb', line 37 def to_s "[#{command}] => #{exit_code}, #{output.to_s.bytesize} bytes, #{duration} seconds" end |