class LoLBase::RankedStats
Attributes
last_modified[R]
overall[R]
Public Class Methods
new(data)
click to toggle source
# File lib/lolbase/data/stats.rb, line 102 def initialize(data) @data = data parse data self end
Public Instance Methods
all()
click to toggle source
# File lib/lolbase/data/stats.rb, line 120 def all return @parsed_data end
find(criteria = {})
click to toggle source
# File lib/lolbase/data/stats.rb, line 112 def find(criteria = {}) raise InvalidArgumentError if criteria.class != Hash if criteria[:champion_id] return @parsed_data.select { |item| item.id == criteria[:champion_id] }.first end nil end
raw_json()
click to toggle source
# File lib/lolbase/data/stats.rb, line 108 def raw_json @data end
Private Instance Methods
parse(data)
click to toggle source
# File lib/lolbase/data/stats.rb, line 126 def parse(data) @parsed_data = [] data = JSON.parse data @last_modified = Time.at(data["modifyDate"] / 1000) data["champions"].each do |c| # Overall stats are combined with champion stats in the raw JSON data - # split it out if c["id"] == 0 @overall = c["stats"] else @parsed_data << Champion.new({ id: c["id"], stats: c["stats"] }) end end end