Class: LoLStat
- Inherits:
-
Object
- Object
- LoLStat
- Defined in:
- lib/LoLStat.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
- #find_summoner_by_id(id) ⇒ Object
- #find_summoner_by_name(name) ⇒ Object
-
#initialize(api_key) ⇒ LoLStat
constructor
A new instance of LoLStat.
Constructor Details
#initialize(api_key) ⇒ LoLStat
Returns a new instance of LoLStat.
11 12 13 |
# File 'lib/LoLStat.rb', line 11 def initialize(api_key) @api_key = api_key.to_s end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/LoLStat.rb', line 10 def api_key @api_key end |
Instance Method Details
#find_summoner_by_id(id) ⇒ Object
14 15 16 17 |
# File 'lib/LoLStat.rb', line 14 def find_summoner_by_id(id) uri = "https://prod.api.pvp.net/api/lol/na/v1.1/summoner/" + id.to_s + "?api_key=" + @api_key return Summoner.new(JSON.parse(Net::HTTP.get_response(URI.parse(uri)).body), @api_key) end |
#find_summoner_by_name(name) ⇒ Object
18 19 20 21 |
# File 'lib/LoLStat.rb', line 18 def find_summoner_by_name(name) uri = "https://prod.api.pvp.net/api/lol/na/v1.1/summoner/by-name/" + URI.encode(name.to_s) + "?api_key=" + @api_key return Summoner.new(JSON.parse(Net::HTTP.get_response(URI.parse(uri)).body), @api_key) end |