Class: RiotAPI::Game
- Inherits:
-
Object
- Object
- RiotAPI::Game
- Defined in:
- lib/riot_api/game.rb
Instance Attribute Summary collapse
-
#statistics ⇒ Object
Returns the value of attribute statistics.
Class Method Summary collapse
-
.recent_games(region, summoner_id) ⇒ Object
Returns the last 10 games for the summoner.
Instance Method Summary collapse
-
#initialize(data) ⇒ Game
constructor
A new instance of Game.
Constructor Details
#initialize(data) ⇒ Game
Returns a new instance of Game.
4 5 6 7 8 9 10 11 12 13 14 |
# 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 |
Instance Attribute Details
#statistics ⇒ Object
Returns the value of attribute statistics.
3 4 5 |
# File 'lib/riot_api/game.rb', line 3 def statistics @statistics end |
Class Method Details
.recent_games(region, summoner_id) ⇒ Object
Returns the last 10 games for the summoner
17 18 19 20 21 22 |
# 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 |