Module: SportsDataApi::Golf

Extended by:
Request
Defined in:
lib/sports_data_api/golf.rb,
lib/sports_data_api/golf/round.rb,
lib/sports_data_api/golf/score.rb,
lib/sports_data_api/golf/course.rb,
lib/sports_data_api/golf/player.rb,
lib/sports_data_api/golf/season.rb,
lib/sports_data_api/golf/pairing.rb,
lib/sports_data_api/golf/summary.rb,
lib/sports_data_api/golf/tournament.rb

Defined Under Namespace

Modules: UrlPaths Classes: Course, Exception, Pairing, Player, Round, Score, Season, Summary, Tournament

Constant Summary collapse

API_VERSION =
2
BASE_URL =
'https://api.sportsdatallc.org/golf-%{access_level}%{version}'
DIR =
File.join(File.dirname(__FILE__), 'golf')
SPORT =
:golf

Class Method Summary collapse

Methods included from Request

response_json, response_xml, response_xml_xpath

Class Method Details

.leaderboard(tour, year, tournament_id) ⇒ Object

fetches leaderboard for a golf tournament



86
87
88
89
90
91
92
93
# File 'lib/sports_data_api/golf.rb', line 86

def leaderboard(tour, year, tournament_id)
  response = response_json UrlPaths::LEADERBOARDS %
    { tour: tour, year: year, tournament_id: tournament_id }

  response['leaderboard'].map do |json|
    Player.new(json)
  end
end

.players(tour, year) ⇒ Object

Fetch all players for a season



41
42
43
44
45
46
47
# File 'lib/sports_data_api/golf.rb', line 41

def players(tour, year)
  response = response_json UrlPaths::PLAYERS % { tour: tour, year: year }

  response['players'].map do |json|
    Player.new(json)
  end
end

.scorecards(tour, year, tournament_id, round) ⇒ Object

fetches scorecards for a golf round



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/sports_data_api/golf.rb', line 69

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['round']['players'].map do |json|
      Player.new(json)
    end
  }
end

.season(tour, year) ⇒ Object

Fetches Golf tournament schedule for a given tour and year



34
35
36
37
38
# File 'lib/sports_data_api/golf.rb', line 34

def season(tour, year)
  response = response_json UrlPaths::SEASON % { tour: tour, year: year }

  Season.new(response)
end

.summary(tour, year, tournament_id) ⇒ Object

Fetch a tournament summary



50
51
52
53
54
55
# File 'lib/sports_data_api/golf.rb', line 50

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) ⇒ Object

Fetch teetimes for a round in a tournament



58
59
60
61
62
63
64
65
66
# File 'lib/sports_data_api/golf.rb', line 58

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['round']['courses'].map do |json|
    Course.new(json)
  end
end