Class: NBA::RotationEntry

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

Overview

Represents a player’s rotation entry in a game

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#game_idString

Returns the game ID

Examples:

entry.game_id #=> "0022400001"


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

attribute :game_id, Shale::Type::String

#in_time_realInteger

Returns the time the player checked in (in tenths of seconds from game start)

Examples:

entry.in_time_real #=> 0


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

attribute :in_time_real, Shale::Type::Integer

#out_time_realInteger

Returns the time the player checked out (in tenths of seconds from game start)

Examples:

entry.out_time_real #=> 4320


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

attribute :out_time_real, Shale::Type::Integer

#player_firstString

Returns the player’s first name

Examples:

entry.player_first #=> "Stephen"


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

attribute :player_first, Shale::Type::String

#player_idInteger

Returns the player ID

Examples:

entry.player_id #=> 201939


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

attribute :player_id, Shale::Type::Integer

#player_lastString

Returns the player’s last name

Examples:

entry.player_last #=> "Curry"


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

attribute :player_last, Shale::Type::String

#player_ptsInteger

Returns the points scored during this stint

Examples:

entry.player_pts #=> 12


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

attribute :player_pts, Shale::Type::Integer

#pt_diffInteger

Returns the point differential during this stint

Examples:

entry.pt_diff #=> 8


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

attribute :pt_diff, Shale::Type::Integer

#team_cityString

Returns the team city

Examples:

entry.team_city #=> "Golden State"


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

attribute :team_city, Shale::Type::String

#team_idInteger

Returns the team ID

Examples:

entry.team_id #=> 1610612744


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

attribute :team_id, Shale::Type::Integer

#team_nameString

Returns the team name

Examples:

entry.team_name #=> "Warriors"


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

attribute :team_name, Shale::Type::String

#usg_pctFloat

Returns the usage percentage during this stint

Examples:

entry.usg_pct #=> 32.5


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

attribute :usg_pct, Shale::Type::Float

Instance Method Details

#durationInteger?

Returns the stint duration in tenths of seconds

Examples:

entry.duration #=> 4320


148
149
150
151
152
# File 'lib/nba/rotation_entry.rb', line 148

def duration
  return unless in_time_real && out_time_real

  out_time_real - in_time_real
end

#gameGame?

Returns the game object

Examples:

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


128
129
130
# File 'lib/nba/rotation_entry.rb', line 128

def game
  Games.find(game_id)
end

#playerPlayer?

Returns the player object

Examples:

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


108
109
110
# File 'lib/nba/rotation_entry.rb', line 108

def player
  Players.find(player_id)
end

#player_nameString

Returns the player’s full name

Examples:

entry.player_name #=> "Stephen Curry"


138
139
140
# File 'lib/nba/rotation_entry.rb', line 138

def player_name
  "#{player_first} #{player_last}".strip
end

#teamTeam?

Returns the team object

Examples:

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


118
119
120
# File 'lib/nba/rotation_entry.rb', line 118

def team
  Teams.find(team_id)
end