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
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
-
.leaderboard(tour, year, tournament_id) ⇒ Object
fetches leaderboard for a golf tournament.
-
.players(tour, year) ⇒ Object
Fetch all players for a season.
-
.scorecards(tour, year, tournament_id, round) ⇒ Object
fetches scorecards for a golf round.
-
.season(tour, year) ⇒ Object
Fetches Golf tournament schedule for a given tour and year.
-
.summary(tour, year, tournament_id) ⇒ Object
Fetch a tournament summary.
-
.tee_times(tour, year, tournament_id, round) ⇒ Object
Fetch teetimes for a round in a tournament.
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
82 83 84 85 86 87 88 89 90 |
# File 'lib/sports_data_api/golf.rb', line 82 def leaderboard(tour, year, tournament_id) tour = validate_tour(tour) response = response_json("/leaderboard/#{tour}/#{year}/tournaments/#{tournament_id}/leaderboard.json") response['leaderboard'].map do |json| Player.new(json) end end |
.players(tour, year) ⇒ Object
Fetch all players for a season
34 35 36 37 38 39 40 41 42 |
# File 'lib/sports_data_api/golf.rb', line 34 def players(tour, year) tour = validate_tour(tour) response = response_json("/profiles/#{tour}/#{year}/players/profiles.json") response['players'].map do |json| Player.new(json) end end |
.scorecards(tour, year, tournament_id, round) ⇒ Object
fetches scorecards for a golf round
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/sports_data_api/golf.rb', line 65 def scorecards(tour, year, tournament_id, round) tour = validate_tour(tour) response = response_json("/scorecards/#{tour}/#{year}/tournaments/#{tournament_id}/rounds/#{round}/scores.json") { round: round, tournament_id: tournament_id, 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
25 26 27 28 29 30 31 |
# File 'lib/sports_data_api/golf.rb', line 25 def season(tour, year) tour = validate_tour(tour) response = response_json("/schedule/#{tour}/#{year}/tournaments/schedule.json") Season.new(response) end |
.summary(tour, year, tournament_id) ⇒ Object
Fetch a tournament summary
45 46 47 48 49 50 51 |
# File 'lib/sports_data_api/golf.rb', line 45 def summary(tour, year, tournament_id) tour = validate_tour(tour) response = response_json("/summary/#{tour}/#{year}/tournaments/#{tournament_id}/summary.json") Summary.new(tour, year, response) end |
.tee_times(tour, year, tournament_id, round) ⇒ Object
Fetch teetimes for a round in a tournament
54 55 56 57 58 59 60 61 62 |
# File 'lib/sports_data_api/golf.rb', line 54 def tee_times(tour, year, tournament_id, round) tour = validate_tour(tour) response = response_json("/teetimes/#{tour}/#{year}/tournaments/#{tournament_id}/rounds/#{round}/teetimes.json") response['round']['courses'].map do |json| Course.new(json) end end |