Class: GameModule

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

Instance Method Summary collapse

Constructor Details

#initialize(sightstone) ⇒ GameModule

Returns a new instance of GameModule.



7
8
9
# File 'lib/sightstone/modules/game_module.rb', line 7

def initialize(sightstone)
  @sightstone = sightstone
end

Instance Method Details

#recent(summoner, optional = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sightstone/modules/game_module.rb', line 11

def recent(summoner, optional={})
  region = optional[:region] || @sightstone.region
 id = if summoner.is_a? Summoner
   summoner.id
 else
   summoner
 end
 uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/game/by-summoner/#{id}/recent"
 
  response = _get_api_response(uri)
  _parse_response(response) { |resp|
    data = JSON.parse(resp)
    return MatchHistory.new(data)
  }
end