class FootballNow::Team

Attributes

draws[RW]
goals_against[RW]
goals_for[RW]
league[RW]
losses[RW]
matches[R]
name[RW]
points[RW]
standing[RW]
wins[RW]

Public Class Methods

all() click to toggle source
# File lib/team.rb, line 38
def self.all
  @@all
end
create_from_hash(team_data) click to toggle source
# File lib/team.rb, line 34
def self.create_from_hash(team_data)
  team = new(team_data[:name], team_data).tap(&:save)
end
find_by_name(team_name) click to toggle source
# File lib/team.rb, line 30
def self.find_by_name(team_name)
  @@all.detect {|team| team.name.downcase == team_name.downcase}
end
new(name, opt={}) click to toggle source
# File lib/team.rb, line 9
def initialize(name, opt={})
  @name = name
  @matches = []
  opt.each {|method, arg| send("#{method}=", arg) if self.respond_to?("#{method}=")}
end
reset() click to toggle source
# File lib/team.rb, line 42
def self.reset
  @@all.clear
end

Public Instance Methods

add_match(match, key) click to toggle source
# File lib/team.rb, line 25
def add_match(match, key)
  match.send("#{key}=", self) unless match.send(key)
  @matches << match
end
league=(league) click to toggle source
# File lib/team.rb, line 20
def league=(league)
  @league = league
  league.add_team(self)
end
save() click to toggle source
# File lib/team.rb, line 15
def save
  @@all << self
  self
end