Class: MLB::TeamHistory

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

Overview

Provides methods for fetching team history from the API

Class Method Summary collapse

Class Method Details

.find(team:) ⇒ Array<Team>

Retrieves historical team records

Examples:

Get history for a team

MLB::TeamHistory.find(team: 147)

Get history for a team object

MLB::TeamHistory.find(team: Team.new(id: 147))

Parameters:

  • team (Integer, Team)

    the team ID or Team object

Returns:

  • (Array<Team>)

    historical team records



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

def self.find(team:)
  params = {teamIds: Utils.extract_id(team)}
  response = CLIENT.get("teams/history?#{Utils.build_query(params)}")
  from_json(response).teams
end