Class: NBA::ShotStat

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

Overview

Represents a player’s shot statistics

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#efg_pctFloat?

Returns effective field goal percentage

Examples:

stat.efg_pct #=> 0.561

Returns:

  • (Float, nil)

    effective field goal percentage



98
# File 'lib/nba/shot_stat.rb', line 98

attribute :efg_pct, Shale::Type::Float

#fg2_pctFloat?

Returns 2-point field goal percentage

Examples:

stat.fg2_pct #=> 0.526

Returns:

  • (Float, nil)

    2-point field goal percentage



130
# File 'lib/nba/shot_stat.rb', line 130

attribute :fg2_pct, Shale::Type::Float

#fg2aFloat?

Returns 2-point field goals attempted

Examples:

stat.fg2a #=> 7.8

Returns:

  • (Float, nil)

    2-point field goals attempted



122
# File 'lib/nba/shot_stat.rb', line 122

attribute :fg2a, Shale::Type::Float

#fg2a_frequencyFloat?

Returns 2-point field goal attempt frequency

Examples:

stat.fg2a_frequency #=> 0.45

Returns:

  • (Float, nil)

    2-point field goal attempt frequency



106
# File 'lib/nba/shot_stat.rb', line 106

attribute :fg2a_frequency, Shale::Type::Float

#fg2mFloat?

Returns 2-point field goals made

Examples:

stat.fg2m #=> 4.1

Returns:

  • (Float, nil)

    2-point field goals made



114
# File 'lib/nba/shot_stat.rb', line 114

attribute :fg2m, Shale::Type::Float

#fg3_pctFloat?

Returns 3-point field goal percentage

Examples:

stat.fg3_pct #=> 0.428

Returns:

  • (Float, nil)

    3-point field goal percentage



162
# File 'lib/nba/shot_stat.rb', line 162

attribute :fg3_pct, Shale::Type::Float

#fg3aFloat?

Returns 3-point field goals attempted

Examples:

stat.fg3a #=> 11.2

Returns:

  • (Float, nil)

    3-point field goals attempted



154
# File 'lib/nba/shot_stat.rb', line 154

attribute :fg3a, Shale::Type::Float

#fg3a_frequencyFloat?

Returns 3-point field goal attempt frequency

Examples:

stat.fg3a_frequency #=> 0.55

Returns:

  • (Float, nil)

    3-point field goal attempt frequency



138
# File 'lib/nba/shot_stat.rb', line 138

attribute :fg3a_frequency, Shale::Type::Float

#fg3mFloat?

Returns 3-point field goals made

Examples:

stat.fg3m #=> 4.8

Returns:

  • (Float, nil)

    3-point field goals made



146
# File 'lib/nba/shot_stat.rb', line 146

attribute :fg3m, Shale::Type::Float

#fg_pctFloat?

Returns field goal percentage

Examples:

stat.fg_pct #=> 0.472

Returns:

  • (Float, nil)

    field goal percentage



90
# File 'lib/nba/shot_stat.rb', line 90

attribute :fg_pct, Shale::Type::Float

#fgaFloat?

Returns field goals attempted

Examples:

stat.fga #=> 15.3

Returns:

  • (Float, nil)

    field goals attempted



82
# File 'lib/nba/shot_stat.rb', line 82

attribute :fga, Shale::Type::Float

#fga_frequencyFloat?

Returns field goal attempt frequency

Examples:

stat.fga_frequency #=> 0.35

Returns:

  • (Float, nil)

    field goal attempt frequency



66
# File 'lib/nba/shot_stat.rb', line 66

attribute :fga_frequency, Shale::Type::Float

#fgmFloat?

Returns field goals made

Examples:

stat.fgm #=> 7.2

Returns:

  • (Float, nil)

    field goals made



74
# File 'lib/nba/shot_stat.rb', line 74

attribute :fgm, Shale::Type::Float

#gInteger?

Returns number of games

Examples:

stat.g #=> 74

Returns:

  • (Integer, nil)

    games



50
# File 'lib/nba/shot_stat.rb', line 50

attribute :g, Shale::Type::Integer

#gpInteger?

Returns games played

Examples:

stat.gp #=> 74

Returns:

  • (Integer, nil)

    games played



42
# File 'lib/nba/shot_stat.rb', line 42

attribute :gp, Shale::Type::Integer

#player_idInteger?

Returns the player ID

Examples:

stat.player_id #=> 201939

Returns:

  • (Integer, nil)

    the player’s ID



18
# File 'lib/nba/shot_stat.rb', line 18

attribute :player_id, Shale::Type::Integer

#player_name_last_firstString?

Returns the player name in “Last, First” format

Examples:

stat.player_name_last_first #=> "Curry, Stephen"

Returns:

  • (String, nil)

    the player’s name (last, first)



26
# File 'lib/nba/shot_stat.rb', line 26

attribute :player_name_last_first, Shale::Type::String

#shot_typeString?

Returns the shot type or category

Examples:

stat.shot_type #=> "Catch and Shoot"

Returns:

  • (String, nil)

    the shot type or category



58
# File 'lib/nba/shot_stat.rb', line 58

attribute :shot_type, Shale::Type::String

#sort_orderInteger?

Returns the sort order

Examples:

stat.sort_order #=> 1

Returns:

  • (Integer, nil)

    the sort order



34
# File 'lib/nba/shot_stat.rb', line 34

attribute :sort_order, Shale::Type::Integer

Instance Method Details

#playerPlayer?

Returns the player who took the shots

Examples:

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

Returns:

  • (Player, nil)

    the player object



170
171
172
# File 'lib/nba/shot_stat.rb', line 170

def player
  Players.find(player_id)
end