Class: NBA::Play

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/nba/play.rb

Overview

Represents a single play in a game’s play-by-play data

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_msg_action_typeInteger

Returns the event message action type

Examples:

play.event_msg_action_type #=> 79

Returns:

  • (Integer)

    the event message action type



36
# File 'lib/nba/play.rb', line 36

attribute :event_msg_action_type, Shale::Type::Integer

#event_msg_typeInteger

Returns the event message type

Examples:

play.event_msg_type #=> 2

Returns:

  • (Integer)

    the event message type



28
# File 'lib/nba/play.rb', line 28

attribute :event_msg_type, Shale::Type::Integer

#event_numInteger

Returns the event number

Examples:

play.event_num #=> 1

Returns:

  • (Integer)

    the event number



20
# File 'lib/nba/play.rb', line 20

attribute :event_num, Shale::Type::Integer

#game_idString

Returns the game ID

Examples:

play.game_id #=> "0022400001"

Returns:

  • (String)

    the game ID



12
# File 'lib/nba/play.rb', line 12

attribute :game_id, Shale::Type::String

#home_descriptionString

Returns the home team’s play description

Examples:

play.home_description #=> "Curry 3PT Jump Shot (3 PTS)"

Returns:

  • (String)

    the home description



68
# File 'lib/nba/play.rb', line 68

attribute :home_description, Shale::Type::String

#neutral_descriptionString

Returns the neutral play description

Examples:

play.neutral_description #=> "Jump Ball"

Returns:

  • (String)

    the neutral description



76
# File 'lib/nba/play.rb', line 76

attribute :neutral_description, Shale::Type::String

#pc_time_stringString

Returns the period clock time string

Examples:

play.pc_time_string #=> "11:45"

Returns:

  • (String)

    the period clock time



60
# File 'lib/nba/play.rb', line 60

attribute :pc_time_string, Shale::Type::String

#periodInteger

Returns the period number

Examples:

play.period #=> 1

Returns:

  • (Integer)

    the period number



44
# File 'lib/nba/play.rb', line 44

attribute :period, Shale::Type::Integer

#player1_idInteger

Returns the first player’s ID

Examples:

play.player1_id #=> 201939

Returns:

  • (Integer)

    the player ID



108
# File 'lib/nba/play.rb', line 108

attribute :player1_id, Shale::Type::Integer

#player1_nameString

Returns the first player’s name

Examples:

play.player1_name #=> "Stephen Curry"

Returns:

  • (String)

    the player name



116
# File 'lib/nba/play.rb', line 116

attribute :player1_name, Shale::Type::String

#player1_team_abbreviationString

Returns the first player’s team abbreviation

Examples:

play.player1_team_abbreviation #=> "GSW"

Returns:

  • (String)

    the team abbreviation



132
# File 'lib/nba/play.rb', line 132

attribute :player1_team_abbreviation, Shale::Type::String

#player1_team_idInteger

Returns the first player’s team ID

Examples:

play.player1_team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



124
# File 'lib/nba/play.rb', line 124

attribute :player1_team_id, Shale::Type::Integer

#player2_idInteger

Returns the second player’s ID

Examples:

play.player2_id #=> 2544

Returns:

  • (Integer)

    the player ID



140
# File 'lib/nba/play.rb', line 140

attribute :player2_id, Shale::Type::Integer

#player2_nameString

Returns the second player’s name

Examples:

play.player2_name #=> "LeBron James"

Returns:

  • (String)

    the player name



148
# File 'lib/nba/play.rb', line 148

attribute :player2_name, Shale::Type::String

#player2_team_abbreviationString

Returns the second player’s team abbreviation

Examples:

play.player2_team_abbreviation #=> "LAL"

Returns:

  • (String)

    the team abbreviation



164
# File 'lib/nba/play.rb', line 164

attribute :player2_team_abbreviation, Shale::Type::String

#player2_team_idInteger

Returns the second player’s team ID

Examples:

play.player2_team_id #=> 1610612747

Returns:

  • (Integer)

    the team ID



156
# File 'lib/nba/play.rb', line 156

attribute :player2_team_id, Shale::Type::Integer

#player3_idInteger

Returns the third player’s ID

Examples:

play.player3_id #=> 203507

Returns:

  • (Integer)

    the player ID



172
# File 'lib/nba/play.rb', line 172

attribute :player3_id, Shale::Type::Integer

#player3_nameString

Returns the third player’s name

Examples:

play.player3_name #=> "Draymond Green"

Returns:

  • (String)

    the player name



180
# File 'lib/nba/play.rb', line 180

attribute :player3_name, Shale::Type::String

#player3_team_abbreviationString

Returns the third player’s team abbreviation

Examples:

play.player3_team_abbreviation #=> "GSW"

Returns:

  • (String)

    the team abbreviation



196
# File 'lib/nba/play.rb', line 196

attribute :player3_team_abbreviation, Shale::Type::String

#player3_team_idInteger

Returns the third player’s team ID

Examples:

play.player3_team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



188
# File 'lib/nba/play.rb', line 188

attribute :player3_team_id, Shale::Type::Integer

#scoreString

Returns the current score

Examples:

play.score #=> "105 - 102"

Returns:

  • (String)

    the score (e.g., “105 - 102”)



92
# File 'lib/nba/play.rb', line 92

attribute :score, Shale::Type::String

#score_marginString

Returns the score margin

Examples:

play.score_margin #=> "3"

Returns:

  • (String)

    the score margin



100
# File 'lib/nba/play.rb', line 100

attribute :score_margin, Shale::Type::String

#video_availableInteger

Returns whether video is available for this play

Examples:

play.video_available #=> 1

Returns:

  • (Integer)

    1 if available, 0 if not



204
# File 'lib/nba/play.rb', line 204

attribute :video_available, Shale::Type::Integer

#visitor_descriptionString

Returns the visitor team’s play description

Examples:

play.visitor_description #=> "James Turnover"

Returns:

  • (String)

    the visitor description



84
# File 'lib/nba/play.rb', line 84

attribute :visitor_description, Shale::Type::String

#wc_time_stringString

Returns the wall clock time string

Examples:

play.wc_time_string #=> "8:05 PM"

Returns:

  • (String)

    the wall clock time



52
# File 'lib/nba/play.rb', line 52

attribute :wc_time_string, Shale::Type::String

Instance Method Details

#descriptionString?

Returns the primary description for this play

Examples:

play.description #=> "Curry 3PT Jump Shot"

Returns:

  • (String, nil)

    the description



212
213
214
# File 'lib/nba/play.rb', line 212

def description
  home_description || visitor_description || neutral_description
end

#gameGame?

Returns the game object for this play

Examples:

play.game #=> #<NBA::Game>

Returns:

  • (Game, nil)

    the game object



222
223
224
# File 'lib/nba/play.rb', line 222

def game
  Games.find(game_id)
end

#player1Player? Also known as: player

Returns the first player involved in this play

Examples:

play.player1 #=> #<NBA::Player>

Returns:

  • (Player, nil)

    the player object



232
233
234
# File 'lib/nba/play.rb', line 232

def player1
  Players.find(player1_id)
end

#player2Player?

Returns the second player involved in this play

Examples:

play.player2 #=> #<NBA::Player>

Returns:

  • (Player, nil)

    the player object



242
243
244
# File 'lib/nba/play.rb', line 242

def player2
  Players.find(player2_id)
end

#player3Player?

Returns the third player involved in this play

Examples:

play.player3 #=> #<NBA::Player>

Returns:

  • (Player, nil)

    the player object



252
253
254
# File 'lib/nba/play.rb', line 252

def player3
  Players.find(player3_id)
end