Class: NBA::LiveAction

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

Overview

Represents a live play-by-play action

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#action_numberInteger

Returns the action number

Examples:

action.action_number #=> 1

Returns:

  • (Integer)

    the action number



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

attribute :action_number, Shale::Type::Integer

#action_typeString

Returns the action type

Examples:

action.action_type #=> "2pt"

Returns:

  • (String)

    the action type



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

attribute :action_type, Shale::Type::String

#clockString

Returns the game clock at time of action

Examples:

action.clock #=> "PT11M47S"

Returns:

  • (String)

    the clock in ISO 8601 duration format



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

attribute :clock, Shale::Type::String

#descriptionString

Returns the play description

Examples:

action.description #=> "Curry Driving Layup"

Returns:

  • (String)

    the description



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

attribute :description, Shale::Type::String

#game_idString

Returns the game ID

Examples:

action.game_id #=> "0022400001"

Returns:

  • (String)

    the game ID



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

attribute :game_id, Shale::Type::String

#is_field_goalInteger

Returns whether this is a field goal attempt

Examples:

action.is_field_goal #=> 1

Returns:

  • (Integer)

    1 if field goal, 0 otherwise



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

attribute :is_field_goal, Shale::Type::Integer

#periodInteger

Returns the period

Examples:

action.period #=> 1

Returns:

  • (Integer)

    the period number



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

attribute :period, Shale::Type::Integer

#period_typeString

Returns the period type

Examples:

action.period_type #=> "REGULAR"

Returns:

  • (String)

    the period type (REGULAR, OVERTIME)



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

attribute :period_type, Shale::Type::String

#player_idInteger

Returns the player ID involved in the action

Examples:

action.player_id #=> 201939

Returns:

  • (Integer)

    the player ID



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

attribute :player_id, Shale::Type::Integer

#player_nameString

Returns the player name

Examples:

action.player_name #=> "Stephen Curry"

Returns:

  • (String)

    the player name



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

attribute :player_name, Shale::Type::String

#player_name_iString

Returns the player name in abbreviated format

Examples:

action.player_name_i #=> "S. Curry"

Returns:

  • (String)

    the abbreviated player name



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

attribute :player_name_i, Shale::Type::String

#points_totalInteger

Returns the points from this action

Examples:

action.points_total #=> 2

Returns:

  • (Integer)

    the points



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

attribute :points_total, Shale::Type::Integer

#qualifierArray<String>

Returns any qualifier for the action

Examples:

action.qualifiers #=> ["DRIVING"]

Returns:

  • (Array<String>)

    the qualifiers



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

attribute :qualifiers, Shale::Type::String, collection: true

#score_awayString

Returns the away team score after this action

Examples:

action.score_away #=> "0"

Returns:

  • (String)

    the away score



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

attribute :score_away, Shale::Type::String

#score_homeString

Returns the home team score after this action

Examples:

action.score_home #=> "2"

Returns:

  • (String)

    the home score



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

attribute :score_home, Shale::Type::String

#shot_distanceFloat

Returns the shot distance

Examples:

action.shot_distance #=> 2.5

Returns:

  • (Float)

    the shot distance in feet



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

attribute :shot_distance, Shale::Type::Float

#shot_resultString

Returns the shot result

Examples:

action.shot_result #=> "Made"

Returns:

  • (String)

    “Made” or “Missed”



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

attribute :shot_result, Shale::Type::String

#sub_typeString

Returns the action subtype

Examples:

action.sub_type #=> "LAYUP"

Returns:

  • (String)

    the action subtype



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

attribute :sub_type, Shale::Type::String

#team_idInteger

Returns the team ID

Examples:

action.team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



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

attribute :team_id, Shale::Type::Integer

#team_tricodeString

Returns the team tricode

Examples:

action.team_tricode #=> "GSW"

Returns:

  • (String)

    the team tricode



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

attribute :team_tricode, Shale::Type::String

#time_actualString

Returns the actual time of the action

Examples:

action.time_actual #=> "2024-10-22T19:10:00Z"

Returns:

  • (String)

    the actual time in UTC



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

attribute :time_actual, Shale::Type::String

#x_legacyFloat

Returns the x coordinate on the court

Examples:

action.x_legacy #=> 5.0

Returns:

  • (Float)

    the x coordinate



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

attribute :x_legacy, Shale::Type::Float

#y_legacyFloat

Returns the y coordinate on the court

Examples:

action.y_legacy #=> 25.0

Returns:

  • (Float)

    the y coordinate



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

attribute :y_legacy, Shale::Type::Float

Instance Method Details

#field_goal?Boolean

Returns whether this is a field goal attempt

Examples:

action.field_goal? #=> true

Returns:

  • (Boolean)

    true if field goal attempt



216
217
218
# File 'lib/nba/live_action.rb', line 216

def field_goal?
  is_field_goal.eql?(1)
end

#made?Boolean

Returns whether this shot was made

Examples:

action.made? #=> true

Returns:

  • (Boolean)

    true if shot was made



226
227
228
# File 'lib/nba/live_action.rb', line 226

def made?
  shot_result.eql?("Made")
end

#missed?Boolean

Returns whether this shot was missed

Examples:

action.missed? #=> true

Returns:

  • (Boolean)

    true if shot was missed



236
237
238
# File 'lib/nba/live_action.rb', line 236

def missed?
  shot_result.eql?("Missed")
end

#playerPlayer?

Returns the player object

Examples:

action.player #=> #<NBA::Player>

Returns:

  • (Player, nil)

    the player object



196
197
198
# File 'lib/nba/live_action.rb', line 196

def player
  Players.find(player_id)
end

#teamTeam?

Returns the team object

Examples:

action.team #=> #<NBA::Team>

Returns:

  • (Team, nil)

    the team object



206
207
208
# File 'lib/nba/live_action.rb', line 206

def team
  Teams.find(team_id)
end