Module: MLBStatsAPI::Teams
- Included in:
- Client
- Defined in:
- lib/mlb_stats_api/teams.rb
Instance Method Summary collapse
- #affiliates(team_id, season: nil) ⇒ Object
- #coaches(team_id, date: nil) ⇒ Object
-
#roster(team_id, type:, date: nil) ⇒ Object
def leaders(team_id) get(“/teams/#team_id/leaders”) end.
- #team(team_id) ⇒ Object
- #teams(*team_ids) ⇒ Object
Instance Method Details
#affiliates(team_id, season: nil) ⇒ Object
29 30 31 |
# File 'lib/mlb_stats_api/teams.rb', line 29 def affiliates(team_id, season: nil) get "/teams/#{team_id}/affiliates", season: season end |
#coaches(team_id, date: nil) ⇒ Object
33 34 35 36 37 |
# File 'lib/mlb_stats_api/teams.rb', line 33 def coaches(team_id, date: nil) date ||= Date.today get "/teams/#{team_id}/coaches", date: date.strftime('%m/%d/%Y') end |
#roster(team_id, type:, date: nil) ⇒ Object
def leaders(team_id)
get("/teams/#{team_id}/leaders")
end
43 44 45 |
# File 'lib/mlb_stats_api/teams.rb', line 43 def roster(team_id, type:, date: nil) get "/teams/#{team_id}/roster/#{type}", date: date.strftime('%m/%d/%Y') end |
#team(team_id) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/mlb_stats_api/teams.rb', line 5 def team(team_id) data = load("mlb_stats_api:teams:#{team_id}") do get("/teams/#{team_id}", hydrate: 'venue(timezone)').dig('teams', 0) end MLBStatsAPI::Team.new data end |
#teams(*team_ids) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/mlb_stats_api/teams.rb', line 13 def teams(*team_ids) teams = ids = [] team_ids.each do |team_id| value = @cache.load("mlb_stats_api:teams:#{team_id}") if value teams << MLBStatsAPI::Team.new(value) else ids << team_id end end teams.concat load_teams_by_id(ids) end |