Class: SportsDataApi::Ncaamb::TournamentList

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/ncaamb/tournament_list.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ 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

#idObject (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

#seasonObject (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

#tournamentsObject (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

#yearObject (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