Class: SportsDataApi::Nhl::Game

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/nhl/game.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#awayObject (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_teamObject (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_idObject (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

#broadcastObject (readonly)

Returns the value of attribute broadcast.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def broadcast
  @broadcast
end

#clockObject (readonly)

Returns the value of attribute clock.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def clock
  @clock
end

#dateObject (readonly)

Returns the value of attribute date.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def date
  @date
end

#homeObject (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_teamObject (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_idObject (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

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def id
  @id
end

#periodObject (readonly)

Returns the value of attribute period.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def period
  @period
end

#scheduledObject (readonly)

Returns the value of attribute scheduled.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def scheduled
  @scheduled
end

#seasonObject (readonly)

Returns the value of attribute season.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def season
  @season
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def status
  @status
end

#venueObject (readonly)

Returns the value of attribute venue.



4
5
6
# File 'lib/sports_data_api/nhl/game.rb', line 4

def venue
  @venue
end

#yearObject (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

#boxscoreObject

Wrapper for Nhl.boxscore TODO

Raises:

  • (NotImplementedError)


51
52
53
# File 'lib/sports_data_api/nhl/game.rb', line 51

def boxscore
  raise NotImplementedError
end

#pbpObject

Wrapper for Nhl.pbp (Nhl.play_by_play) TODO

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/sports_data_api/nhl/game.rb', line 44

def pbp
  raise NotImplementedError
end

#summaryObject

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