Class: MLB::Alumni

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

Overview

Provides methods for fetching team alumni from the API

Class Method Summary collapse

Class Method Details

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

Retrieves alumni for a team

Examples:

Get alumni for a team in a season

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

Get alumni for a team object

MLB::Alumni.find(team: Team.new(id: 147), season: 2024)

Parameters:

  • team (Integer, Team)

    the team ID or Team object

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

    the season year (defaults to current year)

Returns:

  • (Array<Player>)

    the alumni players



23
24
25
26
27
28
# File 'lib/mlb/alumni.rb', line 23

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