Class: NBA::Leader

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

Overview

Represents a statistical leader entry

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoryString

Returns the statistical category

Examples:

leader.category #=> "PTS"

Returns:

  • (String)

    the statistical category



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

attribute :category, Shale::Type::String

#player_idInteger

Returns the player ID

Examples:

leader.player_id #=> 201939

Returns:

  • (Integer)

    the player ID



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

attribute :player_id, Shale::Type::Integer

#player_nameString

Returns the player name

Examples:

leader.player_name #=> "Stephen Curry"

Returns:

  • (String)

    the player name



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

attribute :player_name, Shale::Type::String

#rankInteger

Returns the rank in the category

Examples:

leader.rank #=> 1

Returns:

  • (Integer)

    the rank



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

attribute :rank, Shale::Type::Integer

#team_abbreviationString

Returns the team abbreviation

Examples:

leader.team_abbreviation #=> "GSW"

Returns:

  • (String)

    the team abbreviation



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

attribute :team_abbreviation, Shale::Type::String

#team_idInteger

Returns the team ID

Examples:

leader.team_id #=> 1610612744

Returns:

  • (Integer)

    the team ID



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

attribute :team_id, Shale::Type::Integer

#valueFloat

Returns the statistical value

Examples:

leader.value #=> 32.4

Returns:

  • (Float)

    the statistical value



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

attribute :value, Shale::Type::Float

Instance Method Details

#playerPlayer?

Returns the player object for this leader

Examples:

leader.player #=> #<NBA::Player>
leader.player.college #=> "Davidson"

Returns:

  • (Player, nil)

    the hydrated player object



74
75
76
# File 'lib/nba/leader.rb', line 74

def player
  Players.find(player_id)
end

#teamTeam?

Returns the team object for this leader

Examples:

leader.team #=> #<NBA::Team>
leader.team.name #=> "Golden State Warriors"

Returns:

  • (Team, nil)

    the team object



85
86
87
# File 'lib/nba/leader.rb', line 85

def team
  Teams.find(team_id)
end