Class: SPOT::ListResponse
- Inherits:
-
Object
- Object
- SPOT::ListResponse
- Defined in:
- lib/spot-gps/list_response.rb
Instance Attribute Summary collapse
-
#records ⇒ Object
readonly
Returns the value of attribute records.
Instance Method Summary collapse
-
#initialize(response:, resource_class:, unenveloped_body:) ⇒ ListResponse
constructor
A new instance of ListResponse.
- #response ⇒ Object
Constructor Details
#initialize(response:, resource_class:, unenveloped_body:) ⇒ ListResponse
Returns a new instance of ListResponse.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/spot-gps/list_response.rb', line 5 def initialize(response:, resource_class:, unenveloped_body:) @response = response @resource_class = resource_class @unenveloped_body = unenveloped_body # SPOT returns a Hash, rather than an array of hashes, if there is only # a single record. @unenveloped_body = [@unenveloped_body] if @unenveloped_body.is_a?(Hash) @unenveloped_body = [] if @unenveloped_body.nil? @records = @unenveloped_body.map do |item| @resource_class.new(item) end end |
Instance Attribute Details
#records ⇒ Object (readonly)
Returns the value of attribute records.
3 4 5 |
# File 'lib/spot-gps/list_response.rb', line 3 def records @records end |
Instance Method Details
#response ⇒ Object
20 21 22 |
# File 'lib/spot-gps/list_response.rb', line 20 def response @response end |