module MLBStatsAPI::People

Operations pertaining to players, umpires, and coaches @see statsapi.mlb.com/docs/#tag/person

Public Instance Methods

people(person_ids, options = {})
Alias for: person
person(person_ids, options = {}) click to toggle source

View one or more person's stats and biographical information. @see statsapi.mlb.com/docs/#operation/person

# File lib/mlb_stats_api/people.rb, line 9
def person(person_ids, options = {})
  ids = Array(person_ids)

  result = get('/people', options.merge(personIds: ids)).dig('people')

  return result.first if ids.length == 1

  result
end
Also aliased as: people
person_game_stats(person_id, options = {}) click to toggle source

View a player's stats for a specific game. @see statsapi.mlb.com/docs/#operation/currentGameStats

# File lib/mlb_stats_api/people.rb, line 22
def person_game_stats(person_id, options = {})
  game = options.delete(:gamePk) || 'current'

  get("/people/#{person_id}/stats/game/#{game}", options).dig('stats')
end