Class: Ridley::SSH::ResponseSet
- Inherits:
-
Object
- Object
- Ridley::SSH::ResponseSet
- Defined in:
- lib/ridley/ssh/response_set.rb
Overview
Instance Attribute Summary collapse
- #errors ⇒ Array<SSH::Response> readonly
- #oks ⇒ Array<SSH::Response> readonly
Instance Method Summary collapse
-
#add_error(response) ⇒ Object
Add an “Error” response to the ResponseSet.
-
#add_ok(response) ⇒ Object
Add an “OK” response to the ResponseSet.
-
#first ⇒ SSH::Response
Return one of the responses.
-
#has_errors? ⇒ Boolean
Return true if the response set contains any errors.
-
#initialize ⇒ ResponseSet
constructor
A new instance of ResponseSet.
-
#length ⇒ Integer
Returns how many responses are in the set.
Constructor Details
#initialize ⇒ ResponseSet
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
#errors ⇒ Array<SSH::Response> (readonly)
8 9 10 |
# File 'lib/ridley/ssh/response_set.rb', line 8 def errors @errors end |
#oks ⇒ Array<SSH::Response> (readonly)
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
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
18 19 20 |
# File 'lib/ridley/ssh/response_set.rb', line 18 def add_ok(response) self.oks << response end |
#first ⇒ SSH::Response
Return one of the responses
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
32 33 34 |
# File 'lib/ridley/ssh/response_set.rb', line 32 def has_errors? self.errors.any? end |
#length ⇒ Integer
Returns how many responses are in the set
46 47 48 |
# File 'lib/ridley/ssh/response_set.rb', line 46 def length self.oks.length + self.errors.length end |