Class: NBA::Player

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

Overview

Represents an NBA player

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collegeString

Returns the player’s college

Examples:

player.college #=> "St. Vincent-St. Mary HS (OH)"

Returns:

  • (String)

    the player’s college



89
# File 'lib/nba/player.rb', line 89

attribute :college, Shale::Type::String

#countryString

Returns the player’s country

Examples:

player.country #=> "USA"

Returns:

  • (String)

    the player’s country



97
# File 'lib/nba/player.rb', line 97

attribute :country, Shale::Type::String

#draft_numberInteger

Returns the number the player was drafted

Examples:

player.draft_number #=> 1

Returns:

  • (Integer)

    the number the player was drafted



121
# File 'lib/nba/player.rb', line 121

attribute :draft_number, Shale::Type::Integer

#draft_roundInteger

Returns the round the player was drafted

Examples:

player.draft_round #=> 1

Returns:

  • (Integer)

    the round the player was drafted



113
# File 'lib/nba/player.rb', line 113

attribute :draft_round, Shale::Type::Integer

#draft_yearInteger

Returns the year the player was drafted

Examples:

player.draft_year #=> 2003

Returns:

  • (Integer)

    the year the player was drafted



105
# File 'lib/nba/player.rb', line 105

attribute :draft_year, Shale::Type::Integer

#first_nameString

Returns the player’s first name

Examples:

player.first_name #=> "LeBron"

Returns:

  • (String)

    the player’s first name



33
# File 'lib/nba/player.rb', line 33

attribute :first_name, Shale::Type::String

#full_nameString

Returns the player’s full name

Examples:

player.full_name #=> "LeBron James"

Returns:

  • (String)

    the player’s full name



25
# File 'lib/nba/player.rb', line 25

attribute :full_name, Shale::Type::String

#heightString

Returns the player’s height

Examples:

player.height #=> "6-9"

Returns:

  • (String)

    the player’s height



73
# File 'lib/nba/player.rb', line 73

attribute :height, Shale::Type::String

#idInteger

Returns the unique identifier for the player

Examples:

player.id #=> 2544

Returns:

  • (Integer)

    the unique identifier for the player



17
# File 'lib/nba/player.rb', line 17

attribute :id, Shale::Type::Integer

#is_activeBoolean Also known as: active?

Returns whether the player is currently active

Examples:

player.is_active #=> true

Returns:

  • (Boolean)

    whether the player is currently active



49
# File 'lib/nba/player.rb', line 49

attribute :is_active, Shale::Type::Boolean

#jersey_numberInteger

Returns the player’s jersey number

Examples:

player.jersey_number #=> 23

Returns:

  • (Integer)

    the player’s jersey number



57
# File 'lib/nba/player.rb', line 57

attribute :jersey_number, Shale::Type::Integer

#last_nameString

Returns the player’s last name

Examples:

player.last_name #=> "James"

Returns:

  • (String)

    the player’s last name



41
# File 'lib/nba/player.rb', line 41

attribute :last_name, Shale::Type::String

#positionPosition

Returns the player’s position

Examples:

player.position #=> #<NBA::Position>

Returns:

  • (Position)

    the player’s position



65
# File 'lib/nba/player.rb', line 65

attribute :position, Position

#teamTeam

Returns the player’s current team

Examples:

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

Returns:

  • (Team)

    the player’s current team



129
# File 'lib/nba/player.rb', line 129

attribute :team, Team

#weightInteger

Returns the player’s weight

Examples:

player.weight #=> 250

Returns:

  • (Integer)

    the player’s weight



81
# File 'lib/nba/player.rb', line 81

attribute :weight, Shale::Type::Integer

Instance Method Details

#center?Boolean

Returns whether the player is a center

Examples:

player.center? #=> true

Returns:

  • (Boolean)

    true if the player is a center



199
200
201
# File 'lib/nba/player.rb', line 199

def center?
  position_matches?("C", "Center")
end

#forward?Boolean

Returns whether the player is a forward

Examples:

player.forward? #=> true

Returns:

  • (Boolean)

    true if the player is a forward (small forward or power forward)



189
190
191
# File 'lib/nba/player.rb', line 189

def forward?
  small_forward? || power_forward? || position_matches?("F", "Forward")
end

#guard?Boolean

Returns whether the player is a guard

Examples:

player.guard? #=> true

Returns:

  • (Boolean)

    true if the player is a guard (point guard or shooting guard)



159
160
161
# File 'lib/nba/player.rb', line 159

def guard?
  point_guard? || shooting_guard? || position_matches?("G", "Guard")
end

#point_guard?Boolean

Returns whether the player is a point guard

Examples:

player.point_guard? #=> true

Returns:

  • (Boolean)

    true if the player is a point guard



139
140
141
# File 'lib/nba/player.rb', line 139

def point_guard?
  position_matches?("PG", "Point Guard")
end

#power_forward?Boolean

Returns whether the player is a power forward

Examples:

player.power_forward? #=> true

Returns:

  • (Boolean)

    true if the player is a power forward



179
180
181
# File 'lib/nba/player.rb', line 179

def power_forward?
  position_matches?("PF", "Power Forward")
end

#shooting_guard?Boolean

Returns whether the player is a shooting guard

Examples:

player.shooting_guard? #=> true

Returns:

  • (Boolean)

    true if the player is a shooting guard



149
150
151
# File 'lib/nba/player.rb', line 149

def shooting_guard?
  position_matches?("SG", "Shooting Guard")
end

#small_forward?Boolean

Returns whether the player is a small forward

Examples:

player.small_forward? #=> true

Returns:

  • (Boolean)

    true if the player is a small forward



169
170
171
# File 'lib/nba/player.rb', line 169

def small_forward?
  position_matches?("SF", "Small Forward")
end