Class: SportsDataApi::Ncaamb::Season
- Inherits:
-
Object
- Object
- SportsDataApi::Ncaamb::Season
- Defined in:
- lib/sports_data_api/ncaamb/season.rb
Instance Attribute Summary collapse
-
#games ⇒ Object
readonly
Returns the value of attribute games.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Class Method Summary collapse
-
.valid?(season) ⇒ Boolean
Check if the requested season is a valid NCAAMB season type.
Instance Method Summary collapse
-
#initialize(xml) ⇒ Season
constructor
A new instance of Season.
Constructor Details
#initialize(xml) ⇒ Season
Returns a new instance of Season.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 6 def initialize(xml) if xml.is_a? Nokogiri::XML::NodeSet @id = xml.first["id"] @year = xml.first["year"].to_i @type = xml.first["type"].to_sym @games = xml.first.xpath("games/game").map do |game_xml| Game.new(year: @year, season: @type, xml: game_xml) end end end |
Instance Attribute Details
#games ⇒ Object (readonly)
Returns the value of attribute games.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 4 def games @games end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 4 def id @id end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 4 def type @type end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 4 def year @year end |
Class Method Details
.valid?(season) ⇒ Boolean
Check if the requested season is a valid NCAAMB season type.
The only valid types are: :reg, :pst, :ct
23 24 25 |
# File 'lib/sports_data_api/ncaamb/season.rb', line 23 def self.valid?(season) [:REG, :PST, :CT].include?(season) end |