Merge branch 'master' into rspec
This commit is contained in:
@@ -1,12 +1,11 @@
|
|||||||
|
Sightstone
|
||||||
|
=======
|
||||||
[](https://travis-ci.org/danijoo/Sightstone)
|
[](https://travis-ci.org/danijoo/Sightstone)
|
||||||
[](http://badge.fury.io/rb/sightstone)
|
[](http://badge.fury.io/rb/sightstone)
|
||||||
[](https://gemnasium.com/danijoo/Sightstone)
|
[](https://gemnasium.com/danijoo/Sightstone)
|
||||||
|
[](https://codeclimate.com/github/danijoo/Sightstone)
|
||||||
[](http://inch-pages.github.io/github/danijoo/Sightstone)
|
[](http://inch-pages.github.io/github/danijoo/Sightstone)
|
||||||
|
|
||||||
|
|
||||||
Sightstone
|
|
||||||
=======
|
|
||||||
|
|
||||||
Sightstone is a ruby wrapper for riots league of legends developer api ([http://developer.riotgames.com](http://developer.riotgames.com)). Please note that you need an api key from riot in order to use this gem.
|
Sightstone is a ruby wrapper for riots league of legends developer api ([http://developer.riotgames.com](http://developer.riotgames.com)). Please note that you need an api key from riot in order to use this gem.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,29 @@ class RankedStats
|
|||||||
@summonerId = data['summonerId']
|
@summonerId = data['summonerId']
|
||||||
@modifyDate = data['modifyDate']
|
@modifyDate = data['modifyDate']
|
||||||
@champions = {}
|
@champions = {}
|
||||||
|
@names = {}
|
||||||
|
|
||||||
data['champions'].each do |champ|
|
data['champions'].each do |champ|
|
||||||
id = champ['id']
|
id = champ['id']
|
||||||
@champions[id] = Hash.new unless @champions.has_key? id
|
if(!@champions.has_key?(id))
|
||||||
|
@champions[id] = Hash.new
|
||||||
|
@names[champ['name']] = id
|
||||||
|
end
|
||||||
|
|
||||||
stat_keys = champ['stats'].keys
|
stat_keys = champ['stats'].keys
|
||||||
stat_keys.each do |key|
|
stat_keys.each do |key|
|
||||||
@champions[id][key] = champ['stats'][key]
|
@champions[id][key] = champ['stats'][key]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the statistics of a champion by its normailized name
|
||||||
|
# @param name [String] normalized name or Combined
|
||||||
|
# @return [Hash<String, Fixnum>] A Hash mapping statistic names to their values
|
||||||
|
def get_statistics_by_name(name)
|
||||||
|
if(@names.has_key? name)
|
||||||
|
@champions[@names[name]]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user