Class: WargamingApi::Base

Inherits:
Node
  • Object
show all
Includes:
Util::Http, Util::Params, Util::Uri
Defined in:
lib/wargaming_api/base.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#node

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::Http

#fetch_data

Methods included from Util::Params

#prepare_params

Methods included from Util::Uri

#api_uri

Methods inherited from Node

#define_array, #initialize_as_array, #initialize_as_hash, #initialize_attributes

Methods included from Concern::Attributable

#apply_type, included

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



10
11
12
13
14
15
# File 'lib/wargaming_api/base.rb', line 10

def initialize(params = {})
  @params = prepare_params(params)
  @uri = api_uri(@params)
  @json = fetch_data(@uri).with_indifferent_access
  super(@json[:data])
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



8
9
10
# File 'lib/wargaming_api/base.rb', line 8

def json
  @json
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/wargaming_api/base.rb', line 6

def params
  @params
end

#uriObject (readonly)

Returns the value of attribute uri.



7
8
9
# File 'lib/wargaming_api/base.rb', line 7

def uri
  @uri
end

Class Method Details

.fetch(params = {}) ⇒ Object



17
18
19
# File 'lib/wargaming_api/base.rb', line 17

def self.fetch(params = {})
  self.new(params)
end