Class: Firmenwissen::Response::Base
- Inherits:
-
Object
- Object
- Firmenwissen::Response::Base
- Defined in:
- lib/firmenwissen/response/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#suggestions ⇒ Object
readonly
Returns the value of attribute suggestions.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(http_response) ⇒ Base
constructor
A new instance of Base.
- #status_code ⇒ Object
- #successful? ⇒ Boolean
Constructor Details
#initialize(http_response) ⇒ Base
Returns a new instance of Base.
6 7 8 9 |
# File 'lib/firmenwissen/response/base.rb', line 6 def initialize(http_response) @http_response = http_response @suggestions = build_suggestions end |
Instance Attribute Details
#suggestions ⇒ Object (readonly)
Returns the value of attribute suggestions.
4 5 6 |
# File 'lib/firmenwissen/response/base.rb', line 4 def suggestions @suggestions end |
Instance Method Details
#data ⇒ Object
11 12 13 14 15 |
# File 'lib/firmenwissen/response/base.rb', line 11 def data @data ||= parsed_response.map { |hash| map_keys(hash) } rescue JSON::ParserError raise UnprocessableResponseError, "The response from Firmenwissen could not be processed:\n#{body}" end |
#status_code ⇒ Object
17 18 19 |
# File 'lib/firmenwissen/response/base.rb', line 17 def status_code http_response.code end |
#successful? ⇒ Boolean
21 22 23 |
# File 'lib/firmenwissen/response/base.rb', line 21 def successful? status_code == '200' end |