Class: Ridley::SSH::ResponseSet

Inherits:
Object
  • Object
show all
Defined in:
lib/ridley/ssh/response_set.rb

Overview

Author:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResponseSet

Returns a new instance of ResponseSet.



10
11
12
13
# File 'lib/ridley/ssh/response_set.rb', line 10

def initialize
  @oks = Array.new
  @errors = Array.new
end

Instance Attribute Details

#errorsArray<SSH::Response> (readonly)

Returns:



8
9
10
# File 'lib/ridley/ssh/response_set.rb', line 8

def errors
  @errors
end

#oksArray<SSH::Response> (readonly)

Returns:



6
7
8
# File 'lib/ridley/ssh/response_set.rb', line 6

def oks
  @oks
end

Instance Method Details

#add_error(response) ⇒ Object

Add an “Error” response to the ResponseSet

Parameters:



25
26
27
# File 'lib/ridley/ssh/response_set.rb', line 25

def add_error(response)
  self.errors << response
end

#add_ok(response) ⇒ Object

Add an “OK” response to the ResponseSet

Parameters:



18
19
20
# File 'lib/ridley/ssh/response_set.rb', line 18

def add_ok(response)
  self.oks << response
end

#firstSSH::Response

Return one of the responses

Returns:



39
40
41
# File 'lib/ridley/ssh/response_set.rb', line 39

def first
  (self.oks + self.errors).first
end

#has_errors?Boolean

Return true if the response set contains any errors

Returns:

  • (Boolean)


32
33
34
# File 'lib/ridley/ssh/response_set.rb', line 32

def has_errors?
  self.errors.any?
end

#lengthInteger

Returns how many responses are in the set

Returns:

  • (Integer)


46
47
48
# File 'lib/ridley/ssh/response_set.rb', line 46

def length
  self.oks.length + self.errors.length
end