Class: SportsDataApi::Ncaamb::TournamentSchedule

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year, season, xml) ⇒ TournamentSchedule

Returns a new instance of TournamentSchedule.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 6

def initialize(year, season, xml)
  if xml.is_a? Nokogiri::XML::NodeSet
    @id = xml.first["id"]
    @name = xml.first["name"]
    @year = year.to_i
    @season = season

    @games = xml.first.xpath("round").map { |round_xml|
      games_from_round(round_xml)
    }.flatten
  end
end

Instance Attribute Details

#gamesObject (readonly)

Returns the value of attribute games.



4
5
6
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 4

def games
  @games
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 4

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 4

def name
  @name
end

#seasonObject (readonly)

Returns the value of attribute season.



4
5
6
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 4

def season
  @season
end

#yearObject (readonly)

Returns the value of attribute year.



4
5
6
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 4

def year
  @year
end

Class Method Details

.valid?(season) ⇒ Boolean

Check if the requested tournament is a valid NCAAMB tournament type.

The only valid types are: :reg, :pst, :ct

Returns:

  • (Boolean)


23
24
25
# File 'lib/sports_data_api/ncaamb/tournament_schedule.rb', line 23

def self.valid?(season)
  [:REG, :PST, :CT].include?(season)
end