module SportsDataApi::Golf

Constants

API_VERSION
BASE_URL
DIR
SPORT

Public Class Methods

leaderboard(tour, year, tournament_id) click to toggle source

fetches leaderboard for a golf tournament

# File lib/sports_data_api/golf.rb, line 83
def leaderboard(tour, year, tournament_id)
  response = response_json UrlPaths::LEADERBOARDS %
    { tour: tour, year: year, tournament_id: tournament_id }

  response.fetch('leaderboard', []).map do |json|
    Player.new(json)
  end
end
players(tour, year) click to toggle source

Fetch all players for a season

# File lib/sports_data_api/golf.rb, line 38
def players(tour, year)
  response = response_json UrlPaths::PLAYERS % { tour: tour, year: year }

  response.fetch('players', []).map do |json|
    Player.new(json)
  end
end
scorecards(tour, year, tournament_id, round) click to toggle source

fetches scorecards for a golf round

# File lib/sports_data_api/golf.rb, line 66
def scorecards(tour, year, tournament_id, round)
  response = response_json UrlPaths::SCORECARDS %
    { tour: tour, year: year, tournament_id: tournament_id, round: round }

  {
    round: round,
    tournament_id: tournament_id,
    status: response['round']['status'],
    year: year,
    tour: tour,
    players: (response.dig('round', 'players') || []).map do |json|
      Player.new(json)
    end
  }
end
season(tour, year) click to toggle source

Fetches Golf tournament schedule for a given tour and year

# File lib/sports_data_api/golf.rb, line 31
def season(tour, year)
  response = response_json UrlPaths::SEASON % { tour: tour, year: year }

  Season.new(response)
end
summary(tour, year, tournament_id) click to toggle source

Fetch a tournament summary

# File lib/sports_data_api/golf.rb, line 47
def summary(tour, year, tournament_id)
  response = response_json UrlPaths::SUMMARY %
    { tour: tour, year: year, tournament_id: tournament_id }

  Summary.new(tour, year, response)
end
tee_times(tour, year, tournament_id, round) click to toggle source

Fetch teetimes for a round in a tournament

# File lib/sports_data_api/golf.rb, line 55
def tee_times(tour, year, tournament_id, round)
  response = response_json UrlPaths::TEE_TIMES %
    { tour: tour, year: year, tournament_id: tournament_id, round: round }


  (response.dig('round', 'courses') || []).map do |json|
    Course.new(json)
  end
end