Class: SPOT::ListResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/spot-gps/list_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#recordsObject (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

#responseObject



20
21
22
# File 'lib/spot-gps/list_response.rb', line 20

def response
  @response
end