sightstone 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 243c70edff88cf6ca5d8eb317dd0437f2bbac531
4
- data.tar.gz: 9da5d398a81d48ec7092c1b590ac987d9c12dfab
3
+ metadata.gz: 03ecf96e34045604da8d2b7f9acfb3fcaf877f06
4
+ data.tar.gz: ef7984584413ad9cb2a37d473f455fb87573c910
5
5
  SHA512:
6
- metadata.gz: 5402a448fda8ed420686b8883809dce83ec2628b458df69316a60b12842e7063267e91f2f25deb3333aee3726f025c72a87be0369a19331b42bf431fb4e3f8fb
7
- data.tar.gz: 5f48ca696b4341696d3a713c31d46c3e0c1de0f122cc663ef6d2beb3a7b04f0412f2e27186321e087d123b54fc53bfa904f517bf04222b8160bb5dbc3ce87c4d
6
+ metadata.gz: 5a799483b0723d247ccec6835bd889adabf87668d24cf295612cc5162601e0c2048e36fe5c46ee230bf483a29c7c716361aab472b0f77f8174d702b183fca958
7
+ data.tar.gz: 3ce13ece552482e2d92e91afda5bcedd7999b412adb965dcc8467b1542f26e44c5bf58b20d6a9f6a66e1ce7e0b23f5132b3e1c44bae49e09c08f4e0939b8947f
@@ -3,11 +3,16 @@ require 'sightstone/summoner'
3
3
  require 'sightstone/player_stats_summary'
4
4
  require 'sightstone/ranked_stats'
5
5
 
6
+ # Module to receive stats
6
7
  class StatsModule < SightstoneBaseModule
7
8
  def initialize(sightstone)
8
9
  @sightstone = sightstone
9
10
  end
10
11
 
12
+ # get a summary of stats for a summoner
13
+ # @param [Summoner, Fixnum] summoner summoner object of name
14
+ # @param optional [Hash] optional arguments: :region => replaces default region
15
+ # @ return [PlayerStatsSummaryList] of the summoner
11
16
  def summary(summoner, optional={})
12
17
  region = optional[:region] || @sightstone.region
13
18
  season = optional[:season]
@@ -17,7 +22,7 @@ class StatsModule < SightstoneBaseModule
17
22
  else
18
23
  summoner
19
24
  end
20
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/stats/by-summoner/#{id}/summary"
25
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.2/stats/by-summoner/#{id}/summary"
21
26
  response = if season.nil?
22
27
  _get_api_response(uri)
23
28
  else
@@ -31,6 +36,10 @@ class StatsModule < SightstoneBaseModule
31
36
 
32
37
  end
33
38
 
39
+ # get a summary of stats for a summoner
40
+ # @param [Summoner, Fixnum] summoner summoner object of name
41
+ # @param optional [Hash] optional arguments: :region => replaces default region
42
+ # @ return [RankedStats] of the summoner
34
43
  def ranked(summoner, optional={})
35
44
  region = optional[:region] || @sightstone.region
36
45
  season = optional[:season]
@@ -39,7 +48,7 @@ class StatsModule < SightstoneBaseModule
39
48
  else
40
49
  summoner
41
50
  end
42
- uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.1/stats/by-summoner/#{id}/ranked"
51
+ uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.2/stats/by-summoner/#{id}/ranked"
43
52
  response = if season.nil?
44
53
  _get_api_response(uri)
45
54
  else
@@ -1,11 +1,14 @@
1
1
  require 'sightstone/stat'
2
2
 
3
+ # summary of player statistic
4
+ # @attr [Fixnum] summonerId ID of the summoner
5
+ # @attr [Array<PlayerStatSummary] array of stat summaries for player with given id
3
6
  class PlayerStatsSummaryList
4
7
 
5
8
  attr_accessor :summonerId, :playerStatSummaries
6
9
 
7
10
  def initialize(data)
8
- @summonerId = data['playerStatSummary']
11
+ @summonerId = data['summonerId']
9
12
  @playerStatSummaries = []
10
13
  data['playerStatSummaries'].each do |summary|
11
14
  @playerStatSummaries << PlayerStatSummary.new(summary)
@@ -13,18 +16,24 @@ class PlayerStatsSummaryList
13
16
  end
14
17
  end
15
18
 
19
+ # stat sumary for a queue
20
+ # @attr [Fixnum] wins number of won game
21
+ # @attr [Fixnum] losses number of lost games
22
+ # @attr [Fixnum] modifyDate date of modification as unix date
23
+ # @attr [String] playerStatSummaryType type of the stat (can be: AramUnranked5x5, CoopVsAI, OdinUnranked, RankedPremade3x3, RankedPremade5x5, RankedSolo5x5, RankedTeam3x3, RankedTeam5x5, Unranked, Unranked3x3, OneForAll5x5, FirstBlood1x1, FirstBlood2x2)
24
+ # @attr [Hash<String, Fixnum>] aggregatedStats a hash of all stats (key) and their values.
16
25
  class PlayerStatSummary
17
- attr_accessor :wins, :losses, :modifyDateStr, :modifyDate, :playerStatSummaryType, :aggregatedStats
26
+ attr_accessor :wins, :losses, :modifyDate, :playerStatSummaryType, :aggregatedStats
18
27
 
19
28
  def initialize(data)
20
29
  @wins = data['wins']
21
30
  @losses = data['losses']
22
- @modifyDatStr = data['modifyDateStr']
23
31
  @modifyDate = data['modifyDate']
24
32
  @playerStatSummaryType = data['playerStatSummaryType']
25
- @aggregatedStats = []
26
- data['aggregatedStats'].each do |stat|
27
- @aggregatedStats << Stat.new(data)
33
+ @aggregatedStats = {}
34
+ stat_keys = data['aggregatedStats'].keys
35
+ stat_keys.each do |stat|
36
+ @aggregatedStats[stat] = data['aggregatedStats'][stat]
28
37
  end
29
38
  end
30
39
  end
@@ -1,40 +1,23 @@
1
1
  require 'sightstone/stat'
2
-
2
+ # Ranked stats of a summoner
3
+ # @attr [Fixnum] modifyDate date of last modification
4
+ # @attr [Fixnum] summonerId id of the summoner
5
+ # @attr [Hash<Fixnum, Hash<String, Fixnum>>] champions Statisitc for each champion in a Hash. Each key stands for a champions id (0 is sum of all champs) and returns a Hash<stat, stat_value>.
3
6
  class RankedStats
4
- attr_accessor :champions, :modifyData, :modifyDateStr, :summonerId
7
+ attr_accessor :champions, :modifyDate, :summonerId
5
8
 
6
9
  def initialize(data)
7
10
  @summonerId = data['summonerId']
8
11
  @modifyDate = data['modifyDate']
9
- @modifyDateStr = data['modifyDateStr']
10
- @champions = []
12
+ @champions = {}
11
13
 
12
14
  data['champions'].each do |champ|
13
- @champions << ChampionStats.new(champ)
15
+ id = champ['id']
16
+ @champions[id] = Hash.new unless @champions.has_key? id
17
+ stat_keys = champ['stats'].keys
18
+ stat_keys.each do |key|
19
+ @champions[id][key] = champ['stats'][key]
20
+ end
14
21
  end
15
22
  end
16
23
  end
17
-
18
- class ChampionStats
19
- attr_accessor :id, :name, :stats
20
-
21
- def initialize(data)
22
- @id = data['id']
23
- @name = data['name']
24
- @stats = []
25
-
26
- data['stats'].each do |stat|
27
- @stats << ChampionStat.new(stat)
28
- end
29
- end
30
- end
31
-
32
- class ChampionStat < Stat
33
-
34
- attr_accessor :count
35
-
36
- def initialize(data)
37
- super(data)
38
- @count = data['c']
39
- end
40
- end
@@ -1,8 +1,7 @@
1
1
  class Stat
2
- attr_accessor :id, :name, :value
2
+ attr_accessor :name, :value
3
3
 
4
4
  def initialize(data)
5
- @id = data['id']
6
5
  @name = data['name']
7
6
  @value = if data.has_key? 'value'
8
7
  data['value']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sightstone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2012-12-30 00:00:00.000000000 Z
11
+ date: 2012-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client