Class: MLB::Coaches

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

Overview

Provides methods for fetching team coaching staff from the API

Class Method Summary collapse

Class Method Details

.find(team:, season: nil) ⇒ Array<Job>

Retrieves coaches for a team

Examples:

Get coaches for a team

MLB::Coaches.find(team: 147, season: 2024)

Parameters:

  • team (Team, Integer)

    the team or team ID

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

    the season year (defaults to current year)

Returns:

  • (Array<Job>)

    the coaches



21
22
23
24
25
26
# File 'lib/mlb/coaches.rb', line 21

def self.find(team:, season: nil)
  season ||= Utils.current_season
  team_id = Utils.extract_id(team)
  response = CLIENT.get("teams/#{team_id}/coaches?#{Utils.build_query(season:)}")
  from_json(response).roster
end