Class: StatsModule

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

Instance Method Summary collapse

Constructor Details

#initialize(sightstone) ⇒ StatsModule

Returns a new instance of StatsModule.



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

def initialize(sightstone)
  @sightstone = sightstone
end

Instance Method Details

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



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/sightstone/modules/stats_module.rb', line 34

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.1/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)
    return RankedStats.new(data)
  }

end

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



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sightstone/modules/stats_module.rb', line 11

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.1/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)
    return PlayerStatsSummaryList.new(data)
  }

end