Class: MLB::PostseasonSchedule

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

Overview

Provides methods for fetching postseason schedule data from the API

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#datesArray<ScheduleDate>

Returns the schedule dates

Examples:

schedule.dates #=> [#<MLB::ScheduleDate>, ...]

Returns:



21
# File 'lib/mlb/postseason_schedule.rb', line 21

attribute :dates, ScheduleDate, collection: true

#total_gamesInteger

Returns the total number of games

Examples:

schedule.total_games #=> 43

Returns:

  • (Integer)

    the total games



13
# File 'lib/mlb/postseason_schedule.rb', line 13

attribute :total_games, Shale::Type::Integer

Class Method Details

.games(season: nil) ⇒ Array<ScheduledGame>

Retrieves postseason games for a season

Examples:

Get postseason games for 2024

MLB::PostseasonSchedule.games(season: 2024)

Parameters:

  • season (Integer, nil) (defaults to: nil)

    the season year (defaults to current year)

Returns:



35
36
37
38
39
# File 'lib/mlb/postseason_schedule.rb', line 35

def self.games(season: nil)
  season ||= Utils.current_season
  response = CLIENT.get("schedule/postseason?#{Utils.build_query(season:)}")
  from_json(response).dates.flat_map(&:games)
end