Class: SportsDataApi::Nhl::Game
- Inherits:
-
Object
- Object
- SportsDataApi::Nhl::Game
- Defined in:
- lib/sports_data_api/nhl/game.rb
Instance Attribute Summary collapse
-
#away ⇒ Object
readonly
Returns the value of attribute away.
-
#away_team ⇒ Object
readonly
Returns the value of attribute away_team.
-
#away_team_id ⇒ Object
readonly
Returns the value of attribute away_team_id.
-
#broadcast ⇒ Object
readonly
Returns the value of attribute broadcast.
-
#clock ⇒ Object
readonly
Returns the value of attribute clock.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#home ⇒ Object
readonly
Returns the value of attribute home.
-
#home_team ⇒ Object
readonly
Returns the value of attribute home_team.
-
#home_team_id ⇒ Object
readonly
Returns the value of attribute home_team_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
-
#scheduled ⇒ Object
readonly
Returns the value of attribute scheduled.
-
#season ⇒ Object
readonly
Returns the value of attribute season.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#venue ⇒ Object
readonly
Returns the value of attribute venue.
-
#year ⇒ Object
readonly
Returns the value of attribute year.
Instance Method Summary collapse
-
#boxscore ⇒ Object
Wrapper for Nhl.boxscore TODO.
-
#initialize(args = {}) ⇒ Game
constructor
A new instance of Game.
-
#pbp ⇒ Object
Wrapper for Nhl.pbp (Nhl.play_by_play) TODO.
-
#summary ⇒ Object
Wrapper for Nhl.game_summary TODO.
Constructor Details
#initialize(args = {}) ⇒ Game
Returns a new instance of Game.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/sports_data_api/nhl/game.rb', line 8 def initialize(args={}) xml = args.fetch(:xml) @year = args[:year] ? args[:year].to_i : nil @season = args[:season] ? args[:season].to_sym : nil @date = args[:date] xml = xml.first if xml.is_a? Nokogiri::XML::NodeSet if xml.is_a? Nokogiri::XML::Element @id = xml['id'] @scheduled = Time.parse xml['scheduled'] @home = xml['home_team'] @away = xml['away_team'] @home_team_id = xml['home_team'] @away_team_id = xml['away_team'] @status = xml['status'] @clock = xml['clock'] @period = xml['period'] ? xml['period'].to_i : nil team_xml = xml.xpath('team') @home_team = Team.new(team_xml.first) @away_team = Team.new(team_xml.last) @venue = Venue.new(xml.xpath('venue')) @broadcast = Broadcast.new(xml.xpath('broadcast')) end end |
Instance Attribute Details
#away ⇒ Object (readonly)
Returns the value of attribute away.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def away @away end |
#away_team ⇒ Object (readonly)
Returns the value of attribute away_team.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def away_team @away_team end |
#away_team_id ⇒ Object (readonly)
Returns the value of attribute away_team_id.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def away_team_id @away_team_id end |
#broadcast ⇒ Object (readonly)
Returns the value of attribute broadcast.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def broadcast @broadcast end |
#clock ⇒ Object (readonly)
Returns the value of attribute clock.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def clock @clock end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def date @date end |
#home ⇒ Object (readonly)
Returns the value of attribute home.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def home @home end |
#home_team ⇒ Object (readonly)
Returns the value of attribute home_team.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def home_team @home_team end |
#home_team_id ⇒ Object (readonly)
Returns the value of attribute home_team_id.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def home_team_id @home_team_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def id @id end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def period @period end |
#scheduled ⇒ Object (readonly)
Returns the value of attribute scheduled.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def scheduled @scheduled end |
#season ⇒ Object (readonly)
Returns the value of attribute season.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def season @season end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def status @status end |
#venue ⇒ Object (readonly)
Returns the value of attribute venue.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def venue @venue end |
#year ⇒ Object (readonly)
Returns the value of attribute year.
4 5 6 |
# File 'lib/sports_data_api/nhl/game.rb', line 4 def year @year end |
Instance Method Details
#boxscore ⇒ Object
Wrapper for Nhl.boxscore TODO
51 52 53 |
# File 'lib/sports_data_api/nhl/game.rb', line 51 def boxscore raise NotImplementedError end |
#pbp ⇒ Object
Wrapper for Nhl.pbp (Nhl.play_by_play) TODO
44 45 46 |
# File 'lib/sports_data_api/nhl/game.rb', line 44 def pbp raise NotImplementedError end |
#summary ⇒ Object
Wrapper for Nhl.game_summary TODO
37 38 39 |
# File 'lib/sports_data_api/nhl/game.rb', line 37 def summary Nhl.game_summary(@id) end |