Class: SportDb::LeagueConfig
- Inherits:
-
Object
- Object
- SportDb::LeagueConfig
- Defined in:
- lib/football-timezones/league_config.rb
Defined Under Namespace
Classes: LeagueItem
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
- #add(recs) ⇒ Object
-
#initialize(recs = nil) ⇒ LeagueConfig
constructor
A new instance of LeagueConfig.
Constructor Details
#initialize(recs = nil) ⇒ LeagueConfig
Returns a new instance of LeagueConfig.
10 11 12 13 |
# File 'lib/football-timezones/league_config.rb', line 10 def initialize( recs=nil ) @table = {} add( recs ) if recs end |
Class Method Details
.read(path) ⇒ Object
5 6 7 8 |
# File 'lib/football-timezones/league_config.rb', line 5 def self.read( path ) recs = read_csv( path ) new( recs ) end |
Instance Method Details
#[](key) ⇒ Object
80 |
# File 'lib/football-timezones/league_config.rb', line 80 def [](key) @table[ key.to_s.downcase ]; end |
#add(recs) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/football-timezones/league_config.rb', line 66 def add( recs ) recs.each do |rec| @table[ rec['key'] ] ||= LeagueItem.new ## note: auto-change seasons to season object or nil @table[ rec['key'] ] << { 'name' => rec['name'], 'basename' => rec['basename'], 'start_season' => rec['start_season'].empty? ? nil : Season.parse( rec['start_season'] ), 'end_season' => rec['end_season'].empty? ? nil : Season.parse( rec['end_season'] ), } end end |