Class: Sightstone::StatsModule
- Inherits:
-
SightstoneBaseModule
- Object
- SightstoneBaseModule
- Sightstone::StatsModule
- Defined in:
- lib/sightstone/modules/stats_module.rb
Overview
Module to receive stats
Instance Method Summary collapse
-
#initialize(sightstone) ⇒ StatsModule
constructor
A new instance of StatsModule.
-
#ranked(summoner, optional = {}) ⇒ Object
get a summary of stats for a summoner @ return [RankedStats] of the summoner.
-
#summary(summoner, optional = {}) ⇒ Object
get a summary of stats for a summoner @ return [PlayerStatsSummaryList] of the summoner.
Constructor Details
#initialize(sightstone) ⇒ StatsModule
Returns a new instance of StatsModule.
9 10 11 |
# File 'lib/sightstone/modules/stats_module.rb', line 9 def initialize(sightstone) @sightstone = sightstone end |
Instance Method Details
#ranked(summoner, optional = {}) ⇒ Object
get a summary of stats for a summoner @ return [RankedStats] of the summoner
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/sightstone/modules/stats_module.rb', line 49 def ranked(summoner, optional={}) region = optional[:region] || @sightstone.region season = optional[:season] id = if summoner.is_a? Summoner summoner.id else summoner end uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.2/stats/by-summoner/#{id}/ranked" response = if season.nil? _get_api_response(uri) else _get_api_response(uri, {'season' => season}) end _parse_response(response) { |resp| data = JSON.parse(resp) stats = RankedStats.new(data) if block_given? yield stats else return stats end } end |
#summary(summoner, optional = {}) ⇒ Object
get a summary of stats for a summoner @ return [PlayerStatsSummaryList] of the summoner
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sightstone/modules/stats_module.rb', line 17 def summary(summoner, optional={}) region = optional[:region] || @sightstone.region season = optional[:season] id = if summoner.is_a? Summoner summoner.id else summoner end uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.2/stats/by-summoner/#{id}/summary" response = if season.nil? _get_api_response(uri) else _get_api_response(uri, {'season' => season}) end _parse_response(response) { |resp| data = JSON.parse(resp) statList = PlayerStatsSummaryList.new(data) if block_given? yield statList else return statList end } end |