Class: MLB::PlayerStreak

Inherits:
Shale::Mapper
  • Object
show all
Defined in:
lib/mlb/streaks.rb

Overview

Represents a player’s active streak (hitting streak, on-base streak, etc.)

Constant Summary collapse

STREAK_HITTING =
"hittingStreak".freeze
STREAK_ON_BASE =
"onBaseStreak".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_streakInteger

Returns the current streak length

Examples:

streak.current_streak #=> 15

Returns:

  • (Integer)

    the current streak



43
# File 'lib/mlb/streaks.rb', line 43

attribute :current_streak, Shale::Type::Integer

#current_streak_statString

Returns the stat during the streak

Examples:

streak.current_streak_stat #=> "20-for-58"

Returns:

  • (String)

    the streak stat



51
# File 'lib/mlb/streaks.rb', line 51

attribute :current_streak_stat, Shale::Type::String

#player_idInteger

Returns the player ID

Examples:

streak.player_id #=> 660271

Returns:

  • (Integer)

    the player ID



19
# File 'lib/mlb/streaks.rb', line 19

attribute :player_id, Shale::Type::Integer

#player_nameString

Returns the player name

Examples:

streak.player_name #=> "Shohei Ohtani"

Returns:

  • (String)

    the player name



27
# File 'lib/mlb/streaks.rb', line 27

attribute :player_name, Shale::Type::String

#streak_typeString

Returns the streak type

Examples:

streak.streak_type #=> "hittingStreak"

Returns:

  • (String)

    the streak type



35
# File 'lib/mlb/streaks.rb', line 35

attribute :streak_type, Shale::Type::String

#teamTeam

Returns the player’s team

Examples:

streak.team #=> #<MLB::Team>

Returns:

  • (Team)

    the team



59
# File 'lib/mlb/streaks.rb', line 59

attribute :team, Team

Instance Method Details

#hitting_streak?Boolean

Returns whether this is a hitting streak

Examples:

streak.hitting_streak? #=> true

Returns:

  • (Boolean)

    whether this is a hitting streak



67
# File 'lib/mlb/streaks.rb', line 67

def hitting_streak? = streak_type.eql?(STREAK_HITTING)

#on_base_streak?Boolean

Returns whether this is an on-base streak

Examples:

streak.on_base_streak? #=> false

Returns:

  • (Boolean)

    whether this is an on-base streak



75
# File 'lib/mlb/streaks.rb', line 75

def on_base_streak? = streak_type.eql?(STREAK_ON_BASE)