Class: MLB::StreakCategory

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

Overview

Represents a streaks category

Constant Summary collapse

CATEGORY_HITTING =
"hittingStreak".freeze
CATEGORY_ON_BASE =
"onBaseStreak".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#category_typeString

Returns the streak category type

Examples:

category.category_type #=> "hittingStreak"

Returns:

  • (String)

    the category type



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

attribute :category_type, Shale::Type::String

#streaksArray<PlayerStreak>

Returns the streaks

Examples:

category.streaks #=> [#<MLB::PlayerStreak>, ...]

Returns:



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

attribute :streaks, PlayerStreak, collection: true

Instance Method Details

#hitting_streak?Boolean

Returns whether this is a hitting streak category

Examples:

category.hitting_streak? #=> true

Returns:

  • (Boolean)

    whether this is a hitting streak category



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

def hitting_streak? = category_type.eql?(CATEGORY_HITTING)

#on_base_streak?Boolean

Returns whether this is an on-base streak category

Examples:

category.on_base_streak? #=> false

Returns:

  • (Boolean)

    whether this is an on-base streak category



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

def on_base_streak? = category_type.eql?(CATEGORY_ON_BASE)