Class: MLB::GameType

Inherits:
IdDescriptionType show all
Defined in:
lib/mlb/game_type.rb

Overview

Represents a game type (e.g., Regular Season, Postseason, Spring Training)

Constant Summary collapse

TYPE_REGULAR =

Game type: Regular Season

"R".freeze
TYPE_SPRING =

Game type: Spring Training

"S".freeze
TYPE_EXHIBITION =

Game type: Exhibition

"E".freeze
TYPE_ALL_STAR =

Game type: All-Star Game

"A".freeze
TYPE_WILD_CARD =

Game type: Wild Card

"F".freeze
TYPE_DIVISION =

Game type: Division Series

"D".freeze
TYPE_LCS =

Game type: League Championship Series

"L".freeze
TYPE_WORLD_SERIES =

Game type: World Series

"W".freeze
POSTSEASON_TYPES =

Game type codes that indicate postseason games

%w[F D L W].freeze

Instance Attribute Summary

Attributes inherited from IdDescriptionType

#description, #id

Instance Method Summary collapse

Methods inherited from IdDescriptionType

#to_s

Instance Method Details

#all_star?Boolean

Returns whether this is an All-Star game type

Examples:

game_type.all_star? #=> false

Returns:

  • (Boolean)

    whether this is an All-Star game type



55
# File 'lib/mlb/game_type.rb', line 55

def all_star? = id.eql?(TYPE_ALL_STAR)

#division_series?Boolean

Returns whether this is a Division Series game type

Examples:

game_type.division_series? #=> false

Returns:

  • (Boolean)

    whether this is a Division Series game type



71
# File 'lib/mlb/game_type.rb', line 71

def division_series? = id.eql?(TYPE_DIVISION)

#exhibition?Boolean

Returns whether this is an exhibition game type

Examples:

game_type.exhibition? #=> false

Returns:

  • (Boolean)

    whether this is an exhibition game type



47
# File 'lib/mlb/game_type.rb', line 47

def exhibition? = id.eql?(TYPE_EXHIBITION)

#lcs?Boolean

Returns whether this is a League Championship Series game type

Examples:

game_type.lcs? #=> false

Returns:

  • (Boolean)

    whether this is a League Championship Series game type



79
# File 'lib/mlb/game_type.rb', line 79

def lcs? = id.eql?(TYPE_LCS)

#postseason?Boolean

Returns whether this is a postseason game type

mutant:disable - .to_s is for type safety; include?(nil) returns false anyway

Examples:

game_type.postseason? #=> false

Returns:

  • (Boolean)

    whether this is a postseason game type



96
# File 'lib/mlb/game_type.rb', line 96

def postseason? = POSTSEASON_TYPES.include?(id.to_s)

#regular_season?Boolean

Returns whether this is a regular season game type

Examples:

game_type.regular_season? #=> true

Returns:

  • (Boolean)

    whether this is a regular season game type



31
# File 'lib/mlb/game_type.rb', line 31

def regular_season? = id.eql?(TYPE_REGULAR)

#spring_training?Boolean

Returns whether this is a spring training game type

Examples:

game_type.spring_training? #=> false

Returns:

  • (Boolean)

    whether this is a spring training game type



39
# File 'lib/mlb/game_type.rb', line 39

def spring_training? = id.eql?(TYPE_SPRING)

#wild_card?Boolean

Returns whether this is a Wild Card game type

Examples:

game_type.wild_card? #=> false

Returns:

  • (Boolean)

    whether this is a Wild Card game type



63
# File 'lib/mlb/game_type.rb', line 63

def wild_card? = id.eql?(TYPE_WILD_CARD)

#world_series?Boolean

Returns whether this is a World Series game type

Examples:

game_type.world_series? #=> false

Returns:

  • (Boolean)

    whether this is a World Series game type



87
# File 'lib/mlb/game_type.rb', line 87

def world_series? = id.eql?(TYPE_WORLD_SERIES)