Class: NBA::PlayerComparisonStat

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

Overview

Represents a player comparison stat line

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#astFloat

Returns assists per game

Examples:

stat.ast #=> 6.1

Returns:

  • (Float)

    assists



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

attribute :ast, Shale::Type::Float

#ast_tovFloat

Returns assist to turnover ratio

Examples:

stat.ast_tov #=> 2.18

Returns:

  • (Float)

    assist to turnover ratio



212
# File 'lib/nba/player_comparison_stat.rb', line 212

attribute :ast_tov, Shale::Type::Float

#blkFloat

Returns blocks per game

Examples:

stat.blk #=> 0.3

Returns:

  • (Float)

    blocks



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

attribute :blk, Shale::Type::Float

#drebFloat

Returns defensive rebounds per game

Examples:

stat.dreb #=> 4.3

Returns:

  • (Float)

    defensive rebounds



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

attribute :dreb, Shale::Type::Float

#effFloat

Returns efficiency

Examples:

stat.eff #=> 24.5

Returns:

  • (Float)

    efficiency



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

attribute :eff, Shale::Type::Float

#fg3_pctFloat

Returns three-point percentage

Examples:

stat.fg3_pct #=> 0.417

Returns:

  • (Float)

    three-point percentage



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

attribute :fg3_pct, Shale::Type::Float

#fg3aFloat

Returns three-pointers attempted per game

Examples:

stat.fg3a #=> 11.5

Returns:

  • (Float)

    three-pointers attempted



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

attribute :fg3a, Shale::Type::Float

#fg3mFloat

Returns three-pointers made per game

Examples:

stat.fg3m #=> 4.8

Returns:

  • (Float)

    three-pointers made



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

attribute :fg3m, Shale::Type::Float

#fg_pctFloat

Returns field goal percentage

Examples:

stat.fg_pct #=> 0.494

Returns:

  • (Float)

    field goal percentage



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

attribute :fg_pct, Shale::Type::Float

#fgaFloat

Returns field goals attempted per game

Examples:

stat.fga #=> 17.2

Returns:

  • (Float)

    field goals attempted



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

attribute :fga, Shale::Type::Float

#fgmFloat

Returns field goals made per game

Examples:

stat.fgm #=> 8.5

Returns:

  • (Float)

    field goals made



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

attribute :fgm, Shale::Type::Float

#first_nameString

Returns the player’s first name

Examples:

stat.first_name #=> "Stephen"

Returns:

  • (String)

    the first name



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

attribute :first_name, Shale::Type::String

#ft_pctFloat

Returns free throw percentage

Examples:

stat.ft_pct #=> 0.913

Returns:

  • (Float)

    free throw percentage



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

attribute :ft_pct, Shale::Type::Float

#ftaFloat

Returns free throws attempted per game

Examples:

stat.fta #=> 4.6

Returns:

  • (Float)

    free throws attempted



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

attribute :fta, Shale::Type::Float

#ftmFloat

Returns free throws made per game

Examples:

stat.ftm #=> 4.2

Returns:

  • (Float)

    free throws made



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

attribute :ftm, Shale::Type::Float

#gpInteger

Returns games played

Examples:

stat.gp #=> 74

Returns:

  • (Integer)

    games played



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

attribute :gp, Shale::Type::Integer

#last_nameString

Returns the player’s last name

Examples:

stat.last_name #=> "Curry"

Returns:

  • (String)

    the last name



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

attribute :last_name, Shale::Type::String

#minFloat

Returns minutes per game

Examples:

stat.min #=> 32.5

Returns:

  • (Float)

    minutes per game



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

attribute :min, Shale::Type::Float

#orebFloat

Returns offensive rebounds per game

Examples:

stat.oreb #=> 0.5

Returns:

  • (Float)

    offensive rebounds



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

attribute :oreb, Shale::Type::Float

#pfFloat

Returns personal fouls per game

Examples:

stat.pf #=> 1.8

Returns:

  • (Float)

    personal fouls



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

attribute :pf, Shale::Type::Float

#player_idInteger

Returns the player ID

Examples:

stat.player_id #=> 201939

Returns:

  • (Integer)

    the player ID



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

attribute :player_id, Shale::Type::Integer

#ptsFloat

Returns points per game

Examples:

stat.pts #=> 26.4

Returns:

  • (Float)

    points



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

attribute :pts, Shale::Type::Float

#rebFloat

Returns total rebounds per game

Examples:

stat.reb #=> 4.8

Returns:

  • (Float)

    total rebounds



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

attribute :reb, Shale::Type::Float

#season_idString

Returns the season ID

Examples:

stat.season_id #=> "2024-25"

Returns:

  • (String)

    the season ID



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

attribute :season_id, Shale::Type::String

#stlFloat

Returns steals per game

Examples:

stat.stl #=> 0.9

Returns:

  • (Float)

    steals



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

attribute :stl, Shale::Type::Float

#stl_tovFloat

Returns steal to turnover ratio

Examples:

stat.stl_tov #=> 0.32

Returns:

  • (Float)

    steal to turnover ratio



220
# File 'lib/nba/player_comparison_stat.rb', line 220

attribute :stl_tov, Shale::Type::Float

#tovFloat

Returns turnovers per game

Examples:

stat.tov #=> 2.8

Returns:

  • (Float)

    turnovers



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

attribute :tov, Shale::Type::Float

Instance Method Details

#full_nameString

Returns the full name

Examples:

stat.full_name #=> "Stephen Curry"

Returns:

  • (String)

    the full name



238
239
240
# File 'lib/nba/player_comparison_stat.rb', line 238

def full_name
  "#{first_name} #{last_name}".strip
end

#playerPlayer?

Returns the player object

Examples:

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

Returns:

  • (Player, nil)

    the player object



228
229
230
# File 'lib/nba/player_comparison_stat.rb', line 228

def player
  Players.find(player_id)
end