Class: Sightstone::DatadragonModule

Inherits:
SightstoneBaseModule show all
Defined in:
lib/sightstone/modules/datadragon_module.rb

Instance Method Summary collapse

Constructor Details

#initialize(sightstone) ⇒ DatadragonModule

Returns a new instance of DatadragonModule.



5
6
7
# File 'lib/sightstone/modules/datadragon_module.rb', line 5

def initialize(sightstone)
  @sightstone = sightstone
end

Instance Method Details

#version(optional = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sightstone/modules/datadragon_module.rb', line 9

def version(optional={})
  region = optional[:region] || @sightstone.region
  uri = "https://ddragon.leagueoflegends.com/realms/#{region}.json"
 
  response = _get_api_response(uri)
  _parse_response(response) { |resp|
    data = JSON.parse(resp)
    if block_given?
      yield data['v']
    else
      return data['v']
    end
  }
end