Class: SportsDataApi::Ncaamb::TournamentList
- Inherits:
-
Object
- Object
- SportsDataApi::Ncaamb::TournamentList
- Defined in:
- lib/sports_data_api/ncaamb/tournament_list.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#tournaments ⇒ Object
readonly
Returns the value of attribute tournaments.
-
#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) ⇒ TournamentList
constructor
A new instance of TournamentList.
Constructor Details
#initialize(xml) ⇒ TournamentList
Returns a new instance of TournamentList.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sports_data_api/ncaamb/tournament_list.rb', line 6 def initialize(xml) if xml.is_a? Nokogiri::XML::NodeSet @id = xml.first["id"] @year = xml.first["year"].to_i @season = xml.first["type"].to_sym @tournaments = xml.first.xpath("tournament").map do |tournament_xml| Tournament.new(year: @year, season: @season, xml: tournament_xml) end end end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/tournament_list.rb', line 4 def id @id end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/tournament_list.rb', line 4 def season @season end |
#tournaments ⇒ Object (readonly)
Returns the value of attribute tournaments.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/tournament_list.rb', line 4 def tournaments @tournaments end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/ncaamb/tournament_list.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/tournament_list.rb', line 23 def self.valid?(season) [:REG, :PST, :CT].include?(season) end |