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, Pairing, Player, Round, Score, Season, Summary, Tournament
Constant Summary collapse
- API_VERSION =
2- BASE_URL =
'https://api.sportsdatallc.org/golf-%{access_level}%{version}'- SPORT =
:golf- DIR =
File.join(File.dirname(__FILE__), SPORT.to_s)
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
83 84 85 86 87 88 89 90 |
# 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['leaderboard'].map do |json| Player.new(json) end end |
.players(tour, year) ⇒ Object
Fetch all players for a season
38 39 40 41 42 43 44 |
# File 'lib/sports_data_api/golf.rb', line 38 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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# 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['round']['players'].map do |json| Player.new(json) end } end |
.season(tour, year) ⇒ Object
Fetches Golf tournament schedule for a given tour and year
31 32 33 34 35 |
# 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) ⇒ Object
Fetch a tournament summary
47 48 49 50 51 52 |
# 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) ⇒ Object
Fetch teetimes for a round in a tournament
55 56 57 58 59 60 61 62 63 |
# 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['round']['courses'].map do |json| Course.new(json) end end |