Class: EveOnline::ESI::Collection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, ParsedHeaders
Defined in:
lib/eve_online/esi/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ParsedHeaders

#cache_status, #error_limit_remain, #error_limit_reset, #etag, #ratelimit_group, #ratelimit_limit, #ratelimit_remaining, #ratelimit_used, #request_id, #total_pages

Constructor Details

#initialize(data:, headers: nil) ⇒ Collection

Returns a new instance of Collection.



30
31
32
33
# File 'lib/eve_online/esi/collection.rb', line 30

def initialize(data:, headers: nil)
  @data = data
  @headers = headers
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



13
14
15
# File 'lib/eve_online/esi/collection.rb', line 13

def data
  @data
end

#headersObject (readonly)

Returns the value of attribute headers.



13
14
15
# File 'lib/eve_online/esi/collection.rb', line 13

def headers
  @headers
end

Class Method Details

.from_array(array, type:) ⇒ Object



26
27
28
# File 'lib/eve_online/esi/collection.rb', line 26

def self.from_array(array, type:)
  new(data: array.map { |attributes| type.new(attributes: attributes) })
end

.from_response(response, type:) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/eve_online/esi/collection.rb', line 17

def self.from_response(response, type:)
  body = response.body

  new(
    data: body.map { |attributes| type.new(attributes: attributes) },
    headers: response.headers
  )
end