Class: NBA::GameStreak

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

Overview

Represents a player’s game streak statistics

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#active_streakInteger?

Returns whether the streak is active

Examples:

streak.active_streak #=> 1

Returns:

  • (Integer, nil)

    1 for active, 0 for inactive



56
# File 'lib/nba/game_streak.rb', line 56

attribute :active_streak, Shale::Type::Integer

#end_dateString?

Returns the end date of the streak

Examples:

streak.end_date #=> "2024-11-15"

Returns:

  • (String, nil)

    the end date



48
# File 'lib/nba/game_streak.rb', line 48

attribute :end_date, Shale::Type::String

#first_seasonString?

Returns the first season of the streak

Examples:

streak.first_season #=> "2024-25"

Returns:

  • (String, nil)

    the first season



80
# File 'lib/nba/game_streak.rb', line 80

attribute :first_season, Shale::Type::String

#game_streakInteger?

Returns the number of consecutive games in the streak

Examples:

streak.game_streak #=> 10

Returns:

  • (Integer, nil)

    the streak length



32
# File 'lib/nba/game_streak.rb', line 32

attribute :game_streak, Shale::Type::Integer

#last_seasonString?

Returns the last season of the streak

Examples:

streak.last_season #=> "2024-25"

Returns:

  • (String, nil)

    the last season



72
# File 'lib/nba/game_streak.rb', line 72

attribute :last_season, Shale::Type::String

#num_seasonsInteger?

Returns the number of seasons the streak spans

Examples:

streak.num_seasons #=> 1

Returns:

  • (Integer, nil)

    the number of seasons



64
# File 'lib/nba/game_streak.rb', line 64

attribute :num_seasons, Shale::Type::Integer

#player_idInteger?

Returns the player’s unique identifier

Examples:

streak.player_id #=> 201939

Returns:

  • (Integer, nil)

    the player ID



24
# File 'lib/nba/game_streak.rb', line 24

attribute :player_id, Shale::Type::Integer

#player_nameString?

Returns the player’s name

Examples:

streak.player_name #=> "Curry, Stephen"

Returns:

  • (String, nil)

    the player’s name in “Last, First” format



16
# File 'lib/nba/game_streak.rb', line 16

attribute :player_name, Shale::Type::String

#start_dateString?

Returns the start date of the streak

Examples:

streak.start_date #=> "2024-10-22"

Returns:

  • (String, nil)

    the start date



40
# File 'lib/nba/game_streak.rb', line 40

attribute :start_date, Shale::Type::String

Instance Method Details

#active?Boolean

Returns whether the streak is currently active

Examples:

streak.active? #=> true

Returns:

  • (Boolean)

    true if the streak is active



88
89
90
# File 'lib/nba/game_streak.rb', line 88

def active?
  active_streak.eql?(1)
end

#playerPlayer?

Returns the player associated with this streak

Examples:

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

Returns:

  • (Player, nil)

    the player object for this streak



98
99
100
# File 'lib/nba/game_streak.rb', line 98

def player
  Players.find(player_id)
end