Class: BookingApi::Images::ResponseList
- Inherits:
-
Object
- Object
- BookingApi::Images::ResponseList
- Defined in:
- lib/booking_api/images/response_list.rb
Instance Attribute Summary collapse
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #entries ⇒ Object
-
#initialize(response, exception: nil) ⇒ ResponseList
constructor
A new instance of ResponseList.
- #parsed_entries_from_response ⇒ Object
Constructor Details
#initialize(response, exception: nil) ⇒ ResponseList
Returns a new instance of ResponseList.
7 8 9 10 |
# File 'lib/booking_api/images/response_list.rb', line 7 def initialize(response, exception: nil) @response = response @exception = exception end |
Instance Attribute Details
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
5 6 7 |
# File 'lib/booking_api/images/response_list.rb', line 5 def exception @exception end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
5 6 7 |
# File 'lib/booking_api/images/response_list.rb', line 5 def response @response end |
Instance Method Details
#entries ⇒ Object
12 13 14 |
# File 'lib/booking_api/images/response_list.rb', line 12 def entries @entries ||= parsed_entries_from_response.map {|entry| BookingApi::Images::Image.new(entry)} end |
#parsed_entries_from_response ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/booking_api/images/response_list.rb', line 16 def parsed_entries_from_response if response.body && (response.body.is_a?(Hash) || response.body.is_a?(Array)) response.body else raise JSON::ParserError end end |