Class: MLB::Streak

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

Overview

Represents a team’s streak information

Constant Summary collapse

WINS =

Winning streak type value

"wins".freeze
LOSSES =

Losing streak type value

"losses".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#streak_codeString

Returns the streak code

Examples:

streak.streak_code #=> "W3"

Returns:

  • (String)

    the streak code



49
# File 'lib/mlb/team_record.rb', line 49

attribute :streak_code, Shale::Type::String

#streak_numberInteger

Returns the streak length

Examples:

streak.streak_number #=> 3

Returns:

  • (Integer)

    the streak length



65
# File 'lib/mlb/team_record.rb', line 65

attribute :streak_number, Shale::Type::Integer

#streak_typeString

Returns the streak type

Examples:

streak.streak_type #=> "wins"

Returns:

  • (String)

    the streak type



57
# File 'lib/mlb/team_record.rb', line 57

attribute :streak_type, Shale::Type::String

Instance Method Details

#losing?Boolean

Returns whether this is a losing streak

Examples:

streak.losing? #=> false

Returns:

  • (Boolean)

    true if this is a losing streak



86
# File 'lib/mlb/team_record.rb', line 86

def losing? = streak_type.eql?(LOSSES)

#winning?Boolean

Returns whether this is a winning streak

Examples:

streak.winning? #=> true

Returns:

  • (Boolean)

    true if this is a winning streak



78
# File 'lib/mlb/team_record.rb', line 78

def winning? = streak_type.eql?(WINS)