Class: SportsDataApi::Mlb::Season

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/mlb/season.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Season

Returns a new instance of Season.



6
7
8
9
10
11
12
13
14
15
# File 'lib/sports_data_api/mlb/season.rb', line 6

def initialize(xml)
  xml = xml.first if xml.is_a? Nokogiri::XML::NodeSet
  @year = xml['season_year']
  @games = []
  if xml.is_a? Nokogiri::XML::Element
    xml.xpath('event').each do |event|
      @games << Game.new(year: @year, xml: event)
    end
  end
end

Instance Attribute Details

#gamesObject (readonly)

Returns the value of attribute games.



4
5
6
# File 'lib/sports_data_api/mlb/season.rb', line 4

def games
  @games
end

#yearObject (readonly)

Returns the value of attribute year.



4
5
6
# File 'lib/sports_data_api/mlb/season.rb', line 4

def year
  @year
end