class RiotAPI::Game
Attributes
statistics[R]
Public Class Methods
new(data)
click to toggle source
# File lib/riot_api/game.rb, line 4 def initialize(data) data.each do |key, value| key = key.underscore if key == 'statistics' self.statistics = value else self.class.send(:attr_accessor, key.to_sym) instance_variable_set("@#{key}", value) end end end
recent_games(region, summoner_id)
click to toggle source
Returns the last 10 games for the summoner
# File lib/riot_api/game.rb, line 17 def self.recent_games(region, summoner_id) response = RiotAPI::Client.get(region, "game/by-summoner/#{summoner_id}/recent") response["games"].map do |data| RiotAPI::Game.new(data) end end
Public Instance Methods
statistics=(value)
click to toggle source
# File lib/riot_api/game.rb, line 24 def statistics=(value) @statistics = value.map do |stat| AggregatedStat.new(stat) end end