Class: League

Inherits:
Object
  • Object
show all
Defined in:
lib/league.rb

Constant Summary collapse

LeaguesHash =
{
  :epl => {
    :full_name => "premierleague",
    :top_teams => 4,
    :middle_teams => 5,
    :bottom_teams => 3
  },
  :championship => {
    :full_name => "championship",
    :top_teams => 2,
    :middle_teams => 6,
    :bottom_teams => 3
  },
  :spl => {
    :full_name => "scottishpremierleague",
    :top_teams => 1,
    :middle_teams => 3,
    :bottom_teams => 2
  },
  :liga => {
    :full_name => "laligafootball",
    :top_teams => 3,
    :middle_teams => 6,
    :bottom_teams => 3
  },
  :ligue => {
    :full_name => "ligue1football",
    :top_teams => 3,
    :middle_teams => 4,
    :bottom_teams => 3
  },
  :seriea => {
    :full_name => "serieafootball",
    :top_teams => 3,
    :middle_teams => 5,
    :bottom_teams => 3
  },
  :bundesliga => {
    :full_name => "bundesligafootball",
    :top_teams => 4,
    :middle_teams => 6,
    :bottom_teams => 3
  }
}
@@teams =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bottom_teamsObject

Returns the value of attribute bottom_teams.



3
4
5
# File 'lib/league.rb', line 3

def bottom_teams
  @bottom_teams
end

.league_full_nameObject

Returns the value of attribute league_full_name.



3
4
5
# File 'lib/league.rb', line 3

def league_full_name
  @league_full_name
end

.league_symbolObject

Returns the value of attribute league_symbol.



3
4
5
# File 'lib/league.rb', line 3

def league_symbol
  @league_symbol
end

.longest_team_name_lengthObject

Returns the value of attribute longest_team_name_length.



3
4
5
# File 'lib/league.rb', line 3

def longest_team_name_length
  @longest_team_name_length
end

.middle_teamsObject

Returns the value of attribute middle_teams.



3
4
5
# File 'lib/league.rb', line 3

def middle_teams
  @middle_teams
end

.top_teamsObject

Returns the value of attribute top_teams.



3
4
5
# File 'lib/league.rb', line 3

def top_teams
  @top_teams
end

Class Method Details

.get_longest_team_name_lengthObject



85
86
87
# File 'lib/league.rb', line 85

def self.get_longest_team_name_length
  self.longest_team_name_length ||= self.teams.sort_by {|t| t.name.length }.last.name.length
end

.set_bottom_teamsObject



81
82
83
# File 'lib/league.rb', line 81

def self.set_bottom_teams
  self.bottom_teams = League::LeaguesHash[league_symbol][:bottom_teams]
end

.set_league_full_nameObject



69
70
71
# File 'lib/league.rb', line 69

def self.set_league_full_name
  self.league_full_name = League::LeaguesHash[league_symbol][:full_name]
end

.set_league_info(league_selection) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/league.rb', line 61

def self.set_league_info(league_selection)
  self.league_symbol = league_selection
  self.set_league_full_name
  self.set_top_teams
  self.set_middle_teams
  self.set_bottom_teams
end

.set_middle_teamsObject



77
78
79
# File 'lib/league.rb', line 77

def self.set_middle_teams
  self.middle_teams = League::LeaguesHash[league_symbol][:middle_teams]
end

.set_top_teamsObject



73
74
75
# File 'lib/league.rb', line 73

def self.set_top_teams
  self.top_teams = League::LeaguesHash[league_symbol][:top_teams]
end

.team_countObject



57
58
59
# File 'lib/league.rb', line 57

def self.team_count
  teams.length
end

.teamsObject



53
54
55
# File 'lib/league.rb', line 53

def self.teams
  @@teams
end