Class: EOAT::EveApi
- Inherits:
-
Object
- Object
- EOAT::EveApi
- Defined in:
- lib/eoat/eve_api.rb
Overview
EveApi class - call class. Collects user input, building a url request and passes it to the Request class.
Instance Method Summary collapse
-
#initialize(key_id = '', v_code = '', scope: 'eve', host: 'https://api.eveonline.com') ⇒ EveApi
constructor
A new instance of EveApi.
-
#method_missing(method, **kwargs) ⇒ Object
Create an request according to the method called.
Constructor Details
#initialize(key_id = '', v_code = '', scope: 'eve', host: 'https://api.eveonline.com') ⇒ EveApi
Returns a new instance of EveApi.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/eoat/eve_api.rb', line 17 def initialize(key_id='', v_code='', scope: 'eve', host: 'https://api.eveonline.com') @key_id = key_id.to_s @v_code = v_code.to_s @scope = scope.to_s @host = host.to_s unless key_id.to_s.empty? raise ArgumentError, 'You do not specify vCode' if v_code.to_s.empty? end raise ArgumentError, 'vCode must be string' unless v_code.instance_of? String end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, **kwargs) ⇒ Object
Create an request according to the method called. This is used to dynamically create api calls.
31 32 33 34 |
# File 'lib/eoat/eve_api.rb', line 31 def method_missing(method, **kwargs) uri = create_uri(method.id2name, kwargs) EOAT::Request.new(@host, uri, EOAT::Result::EveType::Result).get end |