Class: NBA::BoxScorePlayerStat

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

Overview

Represents a player's box score statistics for a game

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ast ⇒ Integer

Returns assists

Examples:

stat.ast #=> 11

Returns:

  • (Integer) —

    assists



183
# File 'lib/nba/box_score_player_stat.rb', line 183

attribute :ast, Shale::Type::Integer

#blk ⇒ Integer

Returns blocks

Examples:

stat.blk #=> 1

Returns:

  • (Integer) —

    blocks



199
# File 'lib/nba/box_score_player_stat.rb', line 199

attribute :blk, Shale::Type::Integer

#comment ⇒ String

Returns any comment (e.g., "DNP - Rest")

Examples:

stat.comment #=> "DNP - Rest"

Returns:

  • (String) —

    the comment



71
# File 'lib/nba/box_score_player_stat.rb', line 71

attribute :comment, Shale::Type::String

#dreb ⇒ Integer

Returns defensive rebounds

Examples:

stat.dreb #=> 6

Returns:

  • (Integer) —

    defensive rebounds



167
# File 'lib/nba/box_score_player_stat.rb', line 167

attribute :dreb, Shale::Type::Integer

#fg3_pct ⇒ Float

Returns three-point percentage

Examples:

stat.fg3_pct #=> 0.417

Returns:

  • (Float) —

    three-point percentage



127
# File 'lib/nba/box_score_player_stat.rb', line 127

attribute :fg3_pct, Shale::Type::Float

#fg3a ⇒ Integer

Returns three-pointers attempted

Examples:

stat.fg3a #=> 12

Returns:

  • (Integer) —

    three-pointers attempted



119
# File 'lib/nba/box_score_player_stat.rb', line 119

attribute :fg3a, Shale::Type::Integer

#fg3m ⇒ Integer

Returns three-pointers made

Examples:

stat.fg3m #=> 5

Returns:

  • (Integer) —

    three-pointers made



111
# File 'lib/nba/box_score_player_stat.rb', line 111

attribute :fg3m, Shale::Type::Integer

#fg_pct ⇒ Float

Returns field goal percentage

Examples:

stat.fg_pct #=> 0.500

Returns:

  • (Float) —

    field goal percentage



103
# File 'lib/nba/box_score_player_stat.rb', line 103

attribute :fg_pct, Shale::Type::Float

#fga ⇒ Integer

Returns field goals attempted

Examples:

stat.fga #=> 20

Returns:

  • (Integer) —

    field goals attempted



95
# File 'lib/nba/box_score_player_stat.rb', line 95

attribute :fga, Shale::Type::Integer

#fgm ⇒ Integer

Returns field goals made

Examples:

stat.fgm #=> 10

Returns:

  • (Integer) —

    field goals made



87
# File 'lib/nba/box_score_player_stat.rb', line 87

attribute :fgm, Shale::Type::Integer

#ft_pct ⇒ Float

Returns free throw percentage

Examples:

stat.ft_pct #=> 0.889

Returns:

  • (Float) —

    free throw percentage



151
# File 'lib/nba/box_score_player_stat.rb', line 151

attribute :ft_pct, Shale::Type::Float

#fta ⇒ Integer

Returns free throws attempted

Examples:

stat.fta #=> 9

Returns:

  • (Integer) —

    free throws attempted



143
# File 'lib/nba/box_score_player_stat.rb', line 143

attribute :fta, Shale::Type::Integer

#ftm ⇒ Integer

Returns free throws made

Examples:

stat.ftm #=> 8

Returns:

  • (Integer) —

    free throws made



135
# File 'lib/nba/box_score_player_stat.rb', line 135

attribute :ftm, Shale::Type::Integer

#game_id ⇒ String

Returns the game ID

Examples:

stat.game_id #=> "0022400350"

Returns:

  • (String) —

    the game ID



15
# File 'lib/nba/box_score_player_stat.rb', line 15

attribute :game_id, Shale::Type::String

#min ⇒ String

Returns minutes played

Examples:

stat.min #=> "32:45"

Returns:

  • (String) —

    the minutes played



79
# File 'lib/nba/box_score_player_stat.rb', line 79

attribute :min, Shale::Type::String

#oreb ⇒ Integer

Returns offensive rebounds

Examples:

stat.oreb #=> 2

Returns:

  • (Integer) —

    offensive rebounds



159
# File 'lib/nba/box_score_player_stat.rb', line 159

attribute :oreb, Shale::Type::Integer

#pf ⇒ Integer

Returns personal fouls

Examples:

stat.pf #=> 2

Returns:

  • (Integer) —

    personal fouls



215
# File 'lib/nba/box_score_player_stat.rb', line 215

attribute :pf, Shale::Type::Integer

#player_id ⇒ Integer

Returns the player ID

Examples:

stat.player_id #=> 201939

Returns:

  • (Integer) —

    the player ID



47
# File 'lib/nba/box_score_player_stat.rb', line 47

attribute :player_id, Shale::Type::Integer

#player_name ⇒ String

Returns the player name

Examples:

stat.player_name #=> "Stephen Curry"

Returns:

  • (String) —

    the player name



55
# File 'lib/nba/box_score_player_stat.rb', line 55

attribute :player_name, Shale::Type::String

#plus_minus ⇒ Integer

Returns plus/minus

Examples:

stat.plus_minus #=> 12

Returns:

  • (Integer) —

    plus/minus



231
# File 'lib/nba/box_score_player_stat.rb', line 231

attribute :plus_minus, Shale::Type::Integer

#pts ⇒ Integer

Returns points

Examples:

stat.pts #=> 33

Returns:

  • (Integer) —

    points



223
# File 'lib/nba/box_score_player_stat.rb', line 223

attribute :pts, Shale::Type::Integer

#reb ⇒ Integer

Returns total rebounds

Examples:

stat.reb #=> 8

Returns:

  • (Integer) —

    total rebounds



175
# File 'lib/nba/box_score_player_stat.rb', line 175

attribute :reb, Shale::Type::Integer

#start_position ⇒ String

Returns the starting position

Examples:

stat.start_position #=> "G"

Returns:

  • (String) —

    the starting position



63
# File 'lib/nba/box_score_player_stat.rb', line 63

attribute :start_position, Shale::Type::String

#stl ⇒ Integer

Returns steals

Examples:

stat.stl #=> 3

Returns:

  • (Integer) —

    steals



191
# File 'lib/nba/box_score_player_stat.rb', line 191

attribute :stl, Shale::Type::Integer

#team_abbreviation ⇒ String

Returns the team abbreviation

Examples:

stat.team_abbreviation #=> "GSW"

Returns:

  • (String) —

    the team abbreviation



31
# File 'lib/nba/box_score_player_stat.rb', line 31

attribute :team_abbreviation, Shale::Type::String

#team_city ⇒ String

Returns the team city

Examples:

stat.team_city #=> "Golden State"

Returns:

  • (String) —

    the team city



39
# File 'lib/nba/box_score_player_stat.rb', line 39

attribute :team_city, Shale::Type::String

#team_id ⇒ Integer

Returns the team ID

Examples:

stat.team_id #=> 1610612744

Returns:

  • (Integer) —

    the team ID



23
# File 'lib/nba/box_score_player_stat.rb', line 23

attribute :team_id, Shale::Type::Integer

#tov ⇒ Integer

Returns turnovers

Examples:

stat.tov #=> 4

Returns:

  • (Integer) —

    turnovers



207
# File 'lib/nba/box_score_player_stat.rb', line 207

attribute :tov, Shale::Type::Integer

Instance Method Details

#game ⇒ Game?

Returns the game object for this box score

Examples:

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

Returns:

  • (Game, nil) —

    the game object



269
270
271
# File 'lib/nba/box_score_player_stat.rb', line 269

def game
  Games.find(game_id)
end

#player ⇒ Player?

Returns the player object

Examples:

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

Returns:

  • (Player, nil) —

    the player object



239
240
241
# File 'lib/nba/box_score_player_stat.rb', line 239

def player
  Players.find(player_id)
end

#starter? ⇒ Boolean

Returns whether the player started the game

Examples:

stat.starter? #=> true

Returns:

  • (Boolean) —

    true if the player started



259
260
261
# File 'lib/nba/box_score_player_stat.rb', line 259

def starter?
  !start_position.nil? && !start_position.empty?
end

#team ⇒ Team?

Returns the team object

Examples:

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

Returns:

  • (Team, nil) —

    the team object



249
250
251
# File 'lib/nba/box_score_player_stat.rb', line 249

def team
  Teams.find(team_id)
end