Class: SSHake::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/sshake/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cached: false) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
# File 'lib/sshake/response.rb', line 6

def initialize(cached: false)
  @stdout = ''
  @stderr = ''
  @exit_code = 0
  @bytes_streamed = 0
  @cached = cached
end

Instance Attribute Details

#bytes_streamedObject

Returns the value of attribute bytes_streamed.



14
15
16
# File 'lib/sshake/response.rb', line 14

def bytes_streamed
  @bytes_streamed
end

#commandObject

Returns the value of attribute command.



14
15
16
# File 'lib/sshake/response.rb', line 14

def command
  @command
end

#exit_codeObject

Returns the value of attribute exit_code.



14
15
16
# File 'lib/sshake/response.rb', line 14

def exit_code
  @exit_code
end

#exit_signalObject

Returns the value of attribute exit_signal.



14
15
16
# File 'lib/sshake/response.rb', line 14

def exit_signal
  @exit_signal
end

#finish_timeObject

Returns the value of attribute finish_time.



14
15
16
# File 'lib/sshake/response.rb', line 14

def finish_time
  @finish_time
end

#start_timeObject

Returns the value of attribute start_time.



14
15
16
# File 'lib/sshake/response.rb', line 14

def start_time
  @start_time
end

#stderrObject

Returns the value of attribute stderr.



14
15
16
# File 'lib/sshake/response.rb', line 14

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



14
15
16
# File 'lib/sshake/response.rb', line 14

def stdout
  @stdout
end

Instance Method Details

#cached!Object



24
25
26
# File 'lib/sshake/response.rb', line 24

def cached!
  @cached = true
end

#cached?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/sshake/response.rb', line 20

def cached?
  @cached == true
end

#success?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/sshake/response.rb', line 16

def success?
  @exit_code.zero?
end

#timeObject



28
29
30
# File 'lib/sshake/response.rb', line 28

def time
  (finish_time - start_time).to_i
end

#timeout!Object



36
37
38
# File 'lib/sshake/response.rb', line 36

def timeout!
  @exit_code = -255
end

#timeout?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/sshake/response.rb', line 32

def timeout?
  @exit_code == -255
end