Class: EveOnline::ESI::Collection
- Inherits:
-
Object
- Object
- EveOnline::ESI::Collection
- Extended by:
- Forwardable
- Includes:
- Enumerable, ParsedHeaders
- Defined in:
- lib/eve_online/esi/collection.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, headers: nil) ⇒ Collection
constructor
A new instance of Collection.
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
#data ⇒ Object (readonly)
Returns the value of attribute data.
13 14 15 |
# File 'lib/eve_online/esi/collection.rb', line 13 def data @data end |
#headers ⇒ Object (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 |