Class: Rgcm::Response
- Inherits:
-
Object
- Object
- Rgcm::Response
- Defined in:
- lib/rgcm/response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Instance Method Summary collapse
- #count_failures ⇒ Object
- #count_successes ⇒ Object
- #errors ⇒ Object
- #has_failures? ⇒ Boolean
- #has_successes? ⇒ Boolean
-
#initialize(json) ⇒ Response
constructor
A new instance of Response.
- #results ⇒ Object
- #successes ⇒ Object
Constructor Details
#initialize(json) ⇒ Response
Returns a new instance of Response.
5 6 7 |
# File 'lib/rgcm/response.rb', line 5 def initialize(json) @body = JSON.parse(json, symbolize_names: true) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
3 4 5 |
# File 'lib/rgcm/response.rb', line 3 def body @body end |
Instance Method Details
#count_failures ⇒ Object
17 18 19 |
# File 'lib/rgcm/response.rb', line 17 def count_failures self.body[:failure] end |
#count_successes ⇒ Object
9 10 11 |
# File 'lib/rgcm/response.rb', line 9 def count_successes self.body[:success] end |
#errors ⇒ Object
29 30 31 |
# File 'lib/rgcm/response.rb', line 29 def errors self.results.select { |result| result.key?(:error) } end |
#has_failures? ⇒ Boolean
21 22 23 |
# File 'lib/rgcm/response.rb', line 21 def has_failures? self.count_failures > 0 end |
#has_successes? ⇒ Boolean
13 14 15 |
# File 'lib/rgcm/response.rb', line 13 def has_successes? self.count_successes > 0 end |
#results ⇒ Object
25 26 27 |
# File 'lib/rgcm/response.rb', line 25 def results self.body[:results] end |
#successes ⇒ Object
33 34 35 |
# File 'lib/rgcm/response.rb', line 33 def successes self.results.select { |result| !result.key?(:error) } end |