Sha256: b8bc9cf87062cf038546f0be02563805c801ab64d8241ec9ac05b5362b65626e

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true

module MLBStatsAPI
  module Standings
    STANDINGS_TYPES = {
      regular_season: 'regularSeason',
      wild_card: 'wildCard',
      division_leaders: 'divisionLeaders',
      wild_card_with_leaders: 'wildCardWithLeaders',
      first_half: 'firstHalf',
      second_half: 'secondHalf',
      spring_training: 'springTraining',
      post_season: 'postseason',
      by_division: 'byDivision',
      by_conference: 'byConference',
      by_league: 'byLeague'
    }.freeze

    def standings(type:, league_ids:, season: nil)
      raise 'Invalid standings type.' unless STANDINGS_TYPES[type]

      get(
        "/standings/#{STANDINGS_TYPES[type]}",
        leagueId: Array(league_ids).join(','),
        season: (season || Date.today.year)
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mlb_stats_api-0.1.1 lib/mlb_stats_api/standings.rb
mlb_stats_api-0.1.0 lib/mlb_stats_api/standings.rb