Sha256: b1a87ee41a981ed3b8c0aa6997cd8642367ed95ccd9850a8b8c4842d267f11b9

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

# frozen_string_literal: true

module MLBStatsAPI
  # Operations pertaining to leagues
  # @see https://statsapi.mlb.com/docs/#tag/league
  module Leagues
    LEAGUES = {
      american: 103,
      national: 104,
      al: 103,
      nl: 104,
      big_east: 107,
      acc: 108,
      texas: 109,
      california: 110,
      southern: 111,
      pcl: 112,
      eastern: 113,
      cactus: 114,
      grapefruit: 115,
      south_atlantic: 116,
      international: 117,
      midwest: 118
    }.freeze

    # View league information.
    # @see https://statsapi.mlb.com/docs/#operation/league
    def leagues(options = {})
      unless options[:sportId] || options[:leagueIds]
        raise ArgumentError, '#leagues requires a sportId or leagueIds'
      end

      get '/league', options
    end

    # View All-Star Ballots per league.
    # @see https://statsapi.mlb.com/docs/#operation/allStarBallot
    def all_star_ballot(league_id, season = nil, options = {})
      options[:season] = season || Time.now.year

      get "/league/#{league_id}/allStarBallot", options
    end

    # View All-Star Write-ins per league.
    # @see https://statsapi.mlb.com/docs/#operation/allStarWriteIns
    def all_star_write_ins(league_id, season = nil, options = {})
      options[:season] = season || Time.now.year

      get "/league/#{league_id}/allStarWriteIns", options
    end

    # View All-Star Final Vote per league.
    # @see https://statsapi.mlb.com/docs/#operation/allStarFinalVote
    def all_star_final_vote(league_id, season = nil, options = {})
      options[:season] = season || Time.now.year

      get "/league/#{league_id}/allStarFinalVote", options
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mlb_stats_api-0.2.5 lib/mlb_stats_api/leagues.rb
mlb_stats_api-0.2.4 lib/mlb_stats_api/leagues.rb
mlb_stats_api-0.2.3 lib/mlb_stats_api/leagues.rb
mlb_stats_api-0.2.2 lib/mlb_stats_api/leagues.rb