Class: SportsDataApi::Nfl::PlayByPlay

Inherits:
Object
  • Object
show all
Defined in:
lib/sports_data_api/nfl/play_by_play.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(year, season, week, play_by_play_hash) ⇒ PlayByPlay

Returns a new instance of PlayByPlay.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 7

def initialize(year, season, week, play_by_play_hash)
  @year = year
  @season = season
  @week = week

  @id = play_by_play_hash['id']
  @scheduled = Time.parse play_by_play_hash['scheduled']
  @completed = play_by_play_hash['completed'] || Time.parse(play_by_play_hash['scheduled'])
  @home = play_by_play_hash['home'] || play_by_play_hash['home_team']['id']
  @away = play_by_play_hash['away'] || play_by_play_hash['away_team']['id']
  @status = play_by_play_hash['status']

  @home_team = Team.new(play_by_play_hash['home_team'])
  @away_team = Team.new(play_by_play_hash['away_team'])

  @away_team = Team.new(play_by_play_hash['away_team'])

  @quarters = Quarters.new(play_by_play_hash["quarters"])
end

Instance Attribute Details

#awayObject (readonly)

Returns the value of attribute away.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.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/nfl/play_by_play.rb', line 4

def away_team
  @away_team
end

#completedObject (readonly)

Returns the value of attribute completed.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def completed
  @completed
end

#homeObject (readonly)

Returns the value of attribute home.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.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/nfl/play_by_play.rb', line 4

def home_team
  @home_team
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def id
  @id
end

#quartersObject (readonly)

Returns the value of attribute quarters.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def quarters
  @quarters
end

#scheduledObject (readonly)

Returns the value of attribute scheduled.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def scheduled
  @scheduled
end

#seasonObject (readonly)

Returns the value of attribute season.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def season
  @season
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def status
  @status
end

#weekObject (readonly)

Returns the value of attribute week.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def week
  @week
end

#yearObject (readonly)

Returns the value of attribute year.



4
5
6
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 4

def year
  @year
end

Instance Method Details

#boxscoreObject

Wrapper for Nfl.boxscore these helper methods are used to provide similar functionality as the links attribute found in the weekly schedule example.



51
52
53
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 51

def boxscore
  Nfl.boxscore(year, season, week, home, away, 1)
end

#depthchartObject

Wrapper for Nfl.depthchart TODO

Raises:

  • (NotImplementedError)


72
73
74
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 72

def depthchart
  raise NotImplementedError
end

#injuriesObject

Wrapper for Nfl.injuries TODO

Raises:

  • (NotImplementedError)


65
66
67
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 65

def injuries
  raise NotImplementedError
end

#pbpObject

Wrapper for Nfl.pbp (Nfl.play_by_play) TODO

Raises:

  • (NotImplementedError)


43
44
45
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 43

def pbp
  raise NotImplementedError
end

#rosterObject

Wrapper for Nfl.roster TODO

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 58

def roster
  raise NotImplementedError
end

#statisticsObject

Wrapper for Nfl.statistics



29
30
31
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 29

def statistics
  Nfl.game_statistics(year, season, week, home, away, 1)
end

#summaryObject

Wrapper for Nfl.summary TODO

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/sports_data_api/nfl/play_by_play.rb', line 36

def summary
  raise NotImplementedError
end