Class: Vigor::Stats
Instance Attribute Summary collapse
-
#sets ⇒ Object
Returns the value of attribute sets.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(data) ⇒ Stats
constructor
A new instance of Stats.
Constructor Details
#initialize(data) ⇒ Stats
Returns a new instance of Stats.
6 7 8 |
# File 'lib/vigor/stats.rb', line 6 def initialize(data) @sets = data['playerStatSummaries'].map { |set| StatsSet.new(set) } end |
Instance Attribute Details
#sets ⇒ Object
Returns the value of attribute sets.
3 4 5 |
# File 'lib/vigor/stats.rb', line 3 def sets @sets end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/vigor/stats.rb', line 17 def [](key) if key.kind_of?(Integer) return @sets[key] else return @sets.find { |set| set.type.casecmp(key) == 0 } end end |
#each(&block) ⇒ Object
11 12 13 14 15 |
# File 'lib/vigor/stats.rb', line 11 def each(&block) @sets.each do |set| block.call(set) end end |