Class: Stages
- Inherits:
-
Object
- Object
- Stages
- Defined in:
- lib/footballdata/convert-stages.rb
Instance Method Summary collapse
- #add_matches(matches) ⇒ Object
- #as_json ⇒ Object
-
#initialize ⇒ Stages
constructor
A new instance of Stages.
- #size ⇒ Object
Constructor Details
#initialize ⇒ Stages
Returns a new instance of Stages.
3 4 5 |
# File 'lib/footballdata/convert-stages.rb', line 3 def initialize @recs = {} end |
Instance Method Details
#add_matches(matches) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/footballdata/convert-stages.rb', line 7 def add_matches( matches ) matches.each do |m| name = m['stage'] rec = @recs[name] ||= { name: name, count: 0 } rec[:count] +=1 end end |
#as_json ⇒ Object
16 |
# File 'lib/footballdata/convert-stages.rb', line 16 def as_json() @recs.values; end |
#size ⇒ Object
18 |
# File 'lib/footballdata/convert-stages.rb', line 18 def size() @recs.size; end |