From 2f89b8da509c9d5da0379c0e5d072952d023d563 Mon Sep 17 00:00:00 2001 From: danijoo Date: Sat, 22 Mar 2014 02:15:17 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9229d18..9c0bd31 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ +Sightstone +======= [![Build Status](https://travis-ci.org/danijoo/Sightstone.svg?branch=master)](https://travis-ci.org/danijoo/Sightstone) [![Gem Version](https://badge.fury.io/rb/sightstone.png)](http://badge.fury.io/rb/sightstone) [![Dependency Status](https://gemnasium.com/danijoo/Sightstone.svg)](https://gemnasium.com/danijoo/Sightstone) +[![Code Climate](https://codeclimate.com/github/danijoo/Sightstone.png)](https://codeclimate.com/github/danijoo/Sightstone) [![Inline docs](http://inch-pages.github.io/github/danijoo/Sightstone.svg)](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. From 106e943973e6fd0c963b562f5cf26751ee72e4e6 Mon Sep 17 00:00:00 2001 From: danijoo Date: Mon, 24 Mar 2014 11:32:47 +0100 Subject: [PATCH 2/2] added name of champions to ranked stats --- lib/sightstone/ranked_stats.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/sightstone/ranked_stats.rb b/lib/sightstone/ranked_stats.rb index 9fce788..ae9932c 100644 --- a/lib/sightstone/ranked_stats.rb +++ b/lib/sightstone/ranked_stats.rb @@ -10,15 +10,29 @@ class RankedStats @summonerId = data['summonerId'] @modifyDate = data['modifyDate'] @champions = {} + @names = {} data['champions'].each do |champ| 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.each do |key| @champions[id][key] = champ['stats'][key] end end + + # returns the statistics of a champion by its normailized name + # @param name [String] normalized name or Combined + # @return [Hash] 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