Class: SportsDataApi::Nhl::Games

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/sports_data_api/nhl/games.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Games

Returns a new instance of Games.



7
8
9
10
11
12
13
# File 'lib/sports_data_api/nhl/games.rb', line 7

def initialize(xml)
  @date = xml.first['date']

  @games = xml.xpath("games/game").map do |game_xml|
    Game.new(date: @date, xml: game_xml)
  end
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date.



5
6
7
# File 'lib/sports_data_api/nhl/games.rb', line 5

def date
  @date
end

#gamesObject (readonly)

Returns the value of attribute games.



5
6
7
# File 'lib/sports_data_api/nhl/games.rb', line 5

def games
  @games
end

Instance Method Details

#each(&block) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/sports_data_api/nhl/games.rb', line 15

def each &block
  @games.each do |game|
    if block_given?
      block.call game
    else
      yield game
    end
  end
end