updated to game-v1.3

This commit is contained in:
danijoo
2014-01-12 16:27:43 +01:00
parent 352f74dcb9
commit 323395fa5f
4 changed files with 10 additions and 30 deletions

View File

@@ -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<Stat>] statistics statistics of the game
# @attr [Hash<String, Fixnum, Boolean>] 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

View File

@@ -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|

View File

@@ -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"]

View File

@@ -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