Class: RiotAPI::Champion
- Inherits:
-
Object
- Object
- RiotAPI::Champion
- Defined in:
- lib/riot_api/champion.rb
Overview
This class represents a champion in League of Legends. It contains data about the champion.
Class Method Summary collapse
-
.all(free = false) ⇒ Object
Returns all the champions in the game For only the free to play champions, set ‘free` to true.
-
.free_to_play_champions ⇒ Object
Returns all the free to play champions in the game.
Instance Method Summary collapse
-
#initialize(data) ⇒ Champion
constructor
Creates a new Champion described by the JSON data returned from the API.
Constructor Details
#initialize(data) ⇒ Champion
Creates a new Champion described by the JSON data returned from the API
6 7 8 9 10 11 12 |
# File 'lib/riot_api/champion.rb', line 6 def initialize(data) data.each do |key, value| key = key.underscore self.class.send(:attr_accessor, key.to_sym) instance_variable_set("@#{key}", value) end end |
Class Method Details
.all(free = false) ⇒ Object
Returns all the champions in the game For only the free to play champions, set ‘free` to true
16 17 18 19 20 21 |
# File 'lib/riot_api/champion.rb', line 16 def self.all(free=false) champs_json = RiotAPI::Client.get('na', 'champion', { freeToPlay: free }) champs_json["champions"].map do |c| Champion.new(c) end end |
.free_to_play_champions ⇒ Object
Returns all the free to play champions in the game
24 25 26 |
# File 'lib/riot_api/champion.rb', line 24 def self.free_to_play_champions all(true) end |