Class: EveOnline::ESI::Object

Inherits:
Object
  • Object
show all
Includes:
ParsedHeaders
Defined in:
lib/eve_online/esi/object.rb

Instance Attribute 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(attributes: nil, body: nil, headers: nil) ⇒ Object

Returns a new instance of Object.

Parameters:

  • attributes (Hash | NilClass) (defaults to: nil)
  • body (Array<Integer> | NilClass) (defaults to: nil)
  • headers (Hash | NilClass) (defaults to: nil)


15
16
17
18
19
# File 'lib/eve_online/esi/object.rb', line 15

def initialize(attributes: nil, body: nil, headers: nil)
  @attributes = OpenStruct.new(attributes)
  @body = body
  @headers = headers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



21
22
23
24
# File 'lib/eve_online/esi/object.rb', line 21

def method_missing(method, *args, &block)
  attribute = @attributes.public_send(method, *args, &block)
  attribute.is_a?(Hash) ? Object.new(attribute) : attribute
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



10
11
12
# File 'lib/eve_online/esi/object.rb', line 10

def attributes
  @attributes
end

#bodyObject (readonly)

Returns the value of attribute body.



10
11
12
# File 'lib/eve_online/esi/object.rb', line 10

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



10
11
12
# File 'lib/eve_online/esi/object.rb', line 10

def headers
  @headers
end

Instance Method Details

#respond_to_missing?(_, _ = false) ⇒ Boolean

Returns:

  • (Boolean)


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

def respond_to_missing?(_, _ = false)
  true
end