Class: Vigor::Stats

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vigor/stats.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#setsObject

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