Class: SportDb::StandingsHelper::Stats
- Inherits:
-
Object
- Object
- SportDb::StandingsHelper::Stats
- Defined in:
- lib/sportdb/calc.rb
Overview
todo:
add team_id to struct - why? why not? - saves a db lookup?
Instance Attribute Summary collapse
-
#drawn ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#goals_against ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#goals_for ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#lost ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#played ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#pos ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#pts ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#recs ⇒ Object
fix/todo: change/rename :pos to :rank.
-
#won ⇒ Object
fix/todo: change/rename :pos to :rank.
Instance Method Summary collapse
- #add(rec) ⇒ Object
-
#initialize ⇒ Stats
constructor
A new instance of Stats.
Constructor Details
#initialize ⇒ Stats
Returns a new instance of Stats.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sportdb/calc.rb', line 26 def initialize @pos = nil # use 0? why? why not? @played = 0 @won = 0 @lost = 0 @drawn = 0 @goals_for = 0 @goals_against = 0 @pts = 0 @recs = 0 # note: appearances (event) count or similar # is recs counter (number of (stats) records) end |
Instance Attribute Details
#drawn ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def drawn @drawn end |
#goals_against ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def goals_against @goals_against end |
#goals_for ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def goals_for @goals_for end |
#lost ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def lost @lost end |
#played ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def played @played end |
#pos ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def pos @pos end |
#pts ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def pts @pts end |
#recs ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def recs @recs end |
#won ⇒ Object
fix/todo: change/rename :pos to :rank
22 23 24 |
# File 'lib/sportdb/calc.rb', line 22 def won @won end |
Instance Method Details
#add(rec) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/sportdb/calc.rb', line 40 def add( rec ) ### fix: add plus + operator too! # note: will NOT update/add pos (ranking) self.played += rec.played self.won += rec.won self.lost += rec.lost self.drawn += rec.drawn self.goals_for += rec.goals_for self.goals_against += rec.goals_against self.pts += rec.pts self.recs += rec.recs self # return self stats rec end |