Class: SportsDataApi::Mlb::Season
- Inherits:
-
Object
- Object
- SportsDataApi::Mlb::Season
- Defined in:
- lib/sports_data_api/mlb/season.rb
Instance Attribute Summary collapse
-
#games ⇒ Object
readonly
Returns the value of attribute games.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
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 |
# 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
#games ⇒ Object (readonly)
Returns the value of attribute games.
4 5 6 |
# File 'lib/sports_data_api/mlb/season.rb', line 4 def games @games end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/mlb/season.rb', line 4 def year @year end |