Class: Stages

Inherits:
Object
  • Object
show all
Defined in:
lib/footballdata/convert-stages.rb

Instance Method Summary collapse

Constructor Details

#initializeStages

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_jsonObject



16
# File 'lib/footballdata/convert-stages.rb', line 16

def as_json() @recs.values; end

#sizeObject



18
# File 'lib/footballdata/convert-stages.rb', line 18

def size() @recs.size; end