diff --git a/lib/sightstone/match_history.rb b/lib/sightstone/match_history.rb index c24a6de..f32c09b 100644 --- a/lib/sightstone/match_history.rb +++ b/lib/sightstone/match_history.rb @@ -28,7 +28,7 @@ end # @attr [Fixnum] spell2 selected summoner spell no 2 # @attr [String] subtype subtype # @attr [Fixnum] teamId ID of the team if there is a team associated to the game -# @attr [Array] statistics statistics of the game +# @attr [Hash] statistics statistics of the game as a Hash: name -> value class HistoryGame attr_accessor :championId, :createDate, :fellowPlayers, :gameId, :gameMode, :gameType, :invalid, :level, :mapId, :spell1, :spell2, :statistics, :subType, :teamId @@ -50,9 +50,9 @@ class HistoryGame @mapId=data['mapId'] @spell1=data['spell1'] @spell2=data['spell2'] - @statistics = [] - data['statistics'].each do |stat| - @statistics << Stat.new(stat) + @statistics = {} + data['stats'].each do |key, stat| + @statistics[key] = stat end @subType=data['subType'] @teamId=data['teamId'] @@ -73,21 +73,4 @@ class Player end end -# statistical value of a game -# @attr [Fixnum] id ID of the statistical value -# @attr [String] mame name of the statistical value (example: MINIONS_KILLED) -# @attr [Fixnum] value value -class Stat - attr_accessor :id, :name, :value - - def initialize(data) - @name = data['name'] - @id = data['id'] - @value = if data.has_key? 'value' - data['value'] - else - data['count'] - end - end -end end diff --git a/lib/sightstone/modules/game_module.rb b/lib/sightstone/modules/game_module.rb index 658ed9d..80c392a 100644 --- a/lib/sightstone/modules/game_module.rb +++ b/lib/sightstone/modules/game_module.rb @@ -20,7 +20,7 @@ class GameModule < SightstoneBaseModule else summoner end - uri = "https://prod.api.pvp.net/api/lol/#{region}/v1.2/game/by-summoner/#{id}/recent" + 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| diff --git a/sightstone.gemspec b/sightstone.gemspec index f6755df..8256855 100644 --- a/sightstone.gemspec +++ b/sightstone.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'sightstone' - s.version = '1.2.0' - s.date = '2014-01-07' + s.version = '1.3.0' + s.date = '2014-01-12' s.summary = 'Ruby wrapper for riots league of legends api' s.description = s.summary s.authors = ["Daniel Bauer"] diff --git a/test/test_game_module.rb b/test/test_game_module.rb index 13ff07c..c0d44a6 100644 --- a/test/test_game_module.rb +++ b/test/test_game_module.rb @@ -35,17 +35,14 @@ class GameModuleTest < BaseTest assert_instance_of(String, game.subType) assert_instance_of(Fixnum, game.teamId) assert_instance_of(Array, game.fellowPlayers) - assert_instance_of(Array, game.statistics) _check_statistics(game.statistics) _check_fellows(game.fellowPlayers) end def _check_statistics(stats) - stats.each do |stat| - assert_instance_of(Sightstone::Stat, stat) - assert_instance_of(Fixnum, stat.value) - assert_instance_of(Fixnum, stat.id) - assert_instance_of(String, stat.name) + assert_instance_of(Hash, stats) + stats.each do |key, stat| + assert_instance_of(String, key) end end