class FootballNow::Match
Attributes
away_score[RW]
away_team[R]
date[RW]
home_score[RW]
home_team[R]
round[RW]
Public Class Methods
all()
click to toggle source
# File lib/match.rb, line 35 def self.all @@all end
create_from_hash(match_hash)
click to toggle source
# File lib/match.rb, line 26 def self.create_from_hash(match_hash) new(match_hash).tap(&:save) end
get_recent_results(league)
click to toggle source
# File lib/match.rb, line 39 def self.get_recent_results(league) round_number = most_recent_round_number(league) league.matches.select {|match| match.round == round_number} end
most_recent_round_number(league)
click to toggle source
# File lib/match.rb, line 44 def self.most_recent_round_number(league) league.matches.max {|a,b| a.round <=> b.round}.round end
new(opt = {})
click to toggle source
# File lib/match.rb, line 8 def initialize(opt = {}) opt.each {|method, arg| send("#{method}=", arg) if respond_to?("#{method}=") } end
Public Instance Methods
away_team=(team)
click to toggle source
# File lib/match.rb, line 17 def away_team=(team) @away_team = team team.add_match(self, 'away_team') end
home_team=(team)
click to toggle source
# File lib/match.rb, line 12 def home_team=(team) @home_team = team team.add_match(self, 'home_team') end
league()
click to toggle source
# File lib/match.rb, line 22 def league @home_team.league end
save()
click to toggle source
# File lib/match.rb, line 30 def save @@all << self self end