Class: NBA::PlayerIndexEntry

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

Overview

Represents a player from the player index endpoint

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#astFloat

Returns career assists per game

Examples:

entry.ast #=> 6.5

Returns:

  • (Float)

    assists per game



182
# File 'lib/nba/player_index_entry.rb', line 182

attribute :ast, Shale::Type::Float

#collegeString

Returns the player’s college

Examples:

entry.college #=> "Davidson"

Returns:

  • (String)

    the college



118
# File 'lib/nba/player_index_entry.rb', line 118

attribute :college, Shale::Type::String

#countryString

Returns the player’s country

Examples:

entry.country #=> "USA"

Returns:

  • (String)

    the country



126
# File 'lib/nba/player_index_entry.rb', line 126

attribute :country, Shale::Type::String

#draft_numberInteger

Returns the player’s draft pick number

Examples:

entry.draft_number #=> 7

Returns:

  • (Integer)

    the draft number



150
# File 'lib/nba/player_index_entry.rb', line 150

attribute :draft_number, Shale::Type::Integer

#draft_roundInteger

Returns the player’s draft round

Examples:

entry.draft_round #=> 1

Returns:

  • (Integer)

    the draft round



142
# File 'lib/nba/player_index_entry.rb', line 142

attribute :draft_round, Shale::Type::Integer

#draft_yearInteger

Returns the player’s draft year

Examples:

entry.draft_year #=> 2009

Returns:

  • (Integer)

    the draft year



134
# File 'lib/nba/player_index_entry.rb', line 134

attribute :draft_year, Shale::Type::Integer

#first_nameString

Returns the player’s first name

Examples:

entry.first_name #=> "Stephen"

Returns:

  • (String)

    the first name



30
# File 'lib/nba/player_index_entry.rb', line 30

attribute :first_name, Shale::Type::String

#from_yearInteger

Returns the first year played

Examples:

entry.from_year #=> 2009

Returns:

  • (Integer)

    the first year



198
# File 'lib/nba/player_index_entry.rb', line 198

attribute :from_year, Shale::Type::Integer

#heightString

Returns the player’s height

Examples:

entry.height #=> "6-2"

Returns:

  • (String)

    the height



102
# File 'lib/nba/player_index_entry.rb', line 102

attribute :height, Shale::Type::String

#idInteger

Returns the player ID

Examples:

entry.id #=> 201939

Returns:

  • (Integer)

    the player ID



14
# File 'lib/nba/player_index_entry.rb', line 14

attribute :id, Shale::Type::Integer

#is_defunctInteger

Returns whether the player’s team is defunct

Examples:

entry.is_defunct #=> 0

Returns:

  • (Integer)

    defunct flag (0 or 1)



214
# File 'lib/nba/player_index_entry.rb', line 214

attribute :is_defunct, Shale::Type::Integer

#jersey_numberString

Returns the player’s jersey number

Examples:

entry.jersey_number #=> "30"

Returns:

  • (String)

    the jersey number



86
# File 'lib/nba/player_index_entry.rb', line 86

attribute :jersey_number, Shale::Type::String

#last_nameString

Returns the player’s last name

Examples:

entry.last_name #=> "Curry"

Returns:

  • (String)

    the last name



22
# File 'lib/nba/player_index_entry.rb', line 22

attribute :last_name, Shale::Type::String

#positionString

Returns the player’s position

Examples:

entry.position #=> "G"

Returns:

  • (String)

    the position



94
# File 'lib/nba/player_index_entry.rb', line 94

attribute :position, Shale::Type::String

#ptsFloat

Returns career points per game

Examples:

entry.pts #=> 24.8

Returns:

  • (Float)

    points per game



166
# File 'lib/nba/player_index_entry.rb', line 166

attribute :pts, Shale::Type::Float

#rebFloat

Returns career rebounds per game

Examples:

entry.reb #=> 4.7

Returns:

  • (Float)

    rebounds per game



174
# File 'lib/nba/player_index_entry.rb', line 174

attribute :reb, Shale::Type::Float

#roster_statusInteger

Returns the player’s roster status

Examples:

entry.roster_status #=> 1

Returns:

  • (Integer)

    the roster status



158
# File 'lib/nba/player_index_entry.rb', line 158

attribute :roster_status, Shale::Type::Integer

#slugString

Returns the player’s URL slug

Examples:

entry.slug #=> "stephen-curry"

Returns:

  • (String)

    the slug



38
# File 'lib/nba/player_index_entry.rb', line 38

attribute :slug, Shale::Type::String

#stats_timeframeString

Returns the stats timeframe

Examples:

entry.stats_timeframe #=> "Season"

Returns:

  • (String)

    the stats timeframe



190
# File 'lib/nba/player_index_entry.rb', line 190

attribute :stats_timeframe, Shale::Type::String

#team_abbreviationString

Returns the team’s abbreviation

Examples:

entry.team_abbreviation #=> "GSW"

Returns:

  • (String)

    the team abbreviation



78
# File 'lib/nba/player_index_entry.rb', line 78

attribute :team_abbreviation, Shale::Type::String

#team_cityString

Returns the team’s city

Examples:

entry.team_city #=> "Golden State"

Returns:

  • (String)

    the team city



62
# File 'lib/nba/player_index_entry.rb', line 62

attribute :team_city, Shale::Type::String

#team_idInteger

Returns the team ID

Examples:

entry.team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



46
# File 'lib/nba/player_index_entry.rb', line 46

attribute :team_id, Shale::Type::Integer

#team_nameString

Returns the team’s name

Examples:

entry.team_name #=> "Warriors"

Returns:

  • (String)

    the team name



70
# File 'lib/nba/player_index_entry.rb', line 70

attribute :team_name, Shale::Type::String

#team_slugString

Returns the team’s URL slug

Examples:

entry.team_slug #=> "warriors"

Returns:

  • (String)

    the team slug



54
# File 'lib/nba/player_index_entry.rb', line 54

attribute :team_slug, Shale::Type::String

#to_yearInteger

Returns the last year played

Examples:

entry.to_year #=> 2024

Returns:

  • (Integer)

    the last year



206
# File 'lib/nba/player_index_entry.rb', line 206

attribute :to_year, Shale::Type::Integer

#weightInteger

Returns the player’s weight in pounds

Examples:

entry.weight #=> 185

Returns:

  • (Integer)

    the weight



110
# File 'lib/nba/player_index_entry.rb', line 110

attribute :weight, Shale::Type::Integer

Instance Method Details

#active?Boolean

Returns whether the player is currently on a roster

Examples:

entry.active? #=> true

Returns:

  • (Boolean)

    true if on a roster



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

def active?
  roster_status.eql?(1)
end

#defunct?Boolean

Returns whether the player’s team is defunct

Examples:

entry.defunct? #=> false

Returns:

  • (Boolean)

    true if team is defunct



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

def defunct?
  is_defunct.eql?(1)
end

#full_nameString

Returns the player’s full name

Examples:

entry.full_name #=> "Stephen Curry"

Returns:

  • (String)

    the full name



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

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

#playerPlayer?

Returns the player object

Examples:

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

Returns:

  • (Player, nil)

    the player object



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

def player
  Players.find(id)
end

#teamTeam?

Returns the team object

Examples:

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

Returns:

  • (Team, nil)

    the team object



262
263
264
# File 'lib/nba/player_index_entry.rb', line 262

def team
  Teams.find(team_id)
end