class FootballNow::League

Attributes

league_url[RW]
name[RW]
teams[RW]

Public Class Methods

all() click to toggle source
# File lib/league.rb, line 47
def self.all
  @@all
end
create_from_hash(league_hash) click to toggle source
# File lib/league.rb, line 43
def self.create_from_hash(league_hash)
  new_from_hash(league_hash).tap(&:save)
end
find_by_name(name) click to toggle source
# File lib/league.rb, line 35
def self.find_by_name(name)
  self.all.detect {|league| league.name.downcase == name.downcase}
end
get_league_by_index(index) click to toggle source
# File lib/league.rb, line 55
def self.get_league_by_index(index)
  self.all[index]
end
new(name, league_url) click to toggle source
# File lib/league.rb, line 7
def initialize(name, league_url)
  @name = name
  @league_url = league_url
  @teams = []
end
new_from_hash(league_hash) click to toggle source
# File lib/league.rb, line 39
def self.new_from_hash(league_hash)
  new(league_hash[:name], league_hash[:league_url])
end
print_leagues() click to toggle source
reset() click to toggle source
# File lib/league.rb, line 59
def self.reset
  @@all.clear
end

Public Instance Methods

add_team(team) click to toggle source
# File lib/league.rb, line 18
def add_team(team)
  team.league ||= self
  @teams << team unless @teams.include? team
end
current_round() click to toggle source
# File lib/league.rb, line 31
def current_round
  FootballNow::Match.most_recent_round_number(self)
end
get_standings() click to toggle source
# File lib/league.rb, line 27
def get_standings
  @teams.sort {|a, b| a.standing.to_i <=> b.standing.to_i }
end
matches() click to toggle source
# File lib/league.rb, line 23
def matches
  @teams.map { |team| team.matches }.flatten.uniq
end
save() click to toggle source
# File lib/league.rb, line 13
def save
  @@all << self
  self
end