Class: Sightstone::GameModule
- Inherits:
-
SightstoneBaseModule
- Object
- SightstoneBaseModule
- Sightstone::GameModule
- Defined in:
- lib/sightstone/modules/game_module.rb
Overview
module to access the game api
Instance Method Summary collapse
-
#initialize(sightstone) ⇒ GameModule
constructor
A new instance of GameModule.
-
#recent(summoner, optional = {}) ⇒ MatchHistory
returns the match history of a summoner.
Constructor Details
#initialize(sightstone) ⇒ GameModule
Returns a new instance of GameModule.
8 9 10 |
# File 'lib/sightstone/modules/game_module.rb', line 8 def initialize(sightstone) @sightstone = sightstone end |
Instance Method Details
#recent(summoner, optional = {}) ⇒ MatchHistory
returns the match history of a summoner
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sightstone/modules/game_module.rb', line 16 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.3/game/by-summoner/#{id}/recent" response = _get_api_response(uri) _parse_response(response) { |resp| data = JSON.parse(resp) history = MatchHistory.new(data) if block_given? yield history else return history end } end |