Class: TBA
- Inherits:
-
Object
- Object
- TBA
- Defined in:
- lib/tba.rb
Constant Summary collapse
- @@URL_PRE =
'https://www.thebluealliance.com/api/v2/'- @@URL_POST =
'?X-TBA-App-Id='
Instance Method Summary collapse
- #fetch(url) ⇒ Object
- #get_district_events(district, year) ⇒ Object
- #get_district_points(event) ⇒ Object
- #get_district_rankings(district, year) ⇒ Object
- #get_district_teams(district, year) ⇒ Object
- #get_districts(year) ⇒ Object
- #get_event(event) ⇒ Object
- #get_event_awards(event) ⇒ Object
- #get_event_list(*year) ⇒ Object
- #get_event_matches(event) ⇒ Object
- #get_event_rankings(event) ⇒ Object
- #get_event_stats(event) ⇒ Object
- #get_event_teams(event) ⇒ Object
-
#get_match(match) ⇒ Object
TODO: Make this a bit more accessible.
- #get_team(team) ⇒ Object
- #get_team_awards(team, *event) ⇒ Object
- #get_team_events(team, year) ⇒ Object
- #get_team_history_awards(team) ⇒ Object
- #get_team_history_districts(team) ⇒ Object
- #get_team_history_events(team) ⇒ Object
- #get_team_history_robots(team) ⇒ Object
- #get_team_matches(team, event) ⇒ Object
- #get_team_media(team, *year) ⇒ Object
- #get_team_years(team) ⇒ Object
- #get_teams(index) ⇒ Object
-
#initialize(id) ⇒ TBA
constructor
A new instance of TBA.
Constructor Details
#initialize(id) ⇒ TBA
Returns a new instance of TBA.
11 12 13 |
# File 'lib/tba.rb', line 11 def initialize(id) @app_id = id end |
Instance Method Details
#fetch(url) ⇒ Object
15 16 17 |
# File 'lib/tba.rb', line 15 def fetch(url) JSON.parse(Net::HTTP.get(URI.parse(@@URL_PRE + url + @@URL_POST + @app_id))) end |
#get_district_events(district, year) ⇒ Object
116 117 118 |
# File 'lib/tba.rb', line 116 def get_district_events(district, year) fetch('district/' + district + '/' + year + '/events') end |
#get_district_points(event) ⇒ Object
103 104 105 |
# File 'lib/tba.rb', line 103 def get_district_points(event) fetch('event/' + event + '/district_points') end |
#get_district_rankings(district, year) ⇒ Object
120 121 122 |
# File 'lib/tba.rb', line 120 def get_district_rankings(district, year) fetch('district/' + district + '/' + year + '/rankings') end |
#get_district_teams(district, year) ⇒ Object
124 125 126 |
# File 'lib/tba.rb', line 124 def get_district_teams(district, year) fetch('district/' + district + '/' + year + '/teams') end |
#get_districts(year) ⇒ Object
112 113 114 |
# File 'lib/tba.rb', line 112 def get_districts(year) fetch('districts/' + year.to_s) end |
#get_event(event) ⇒ Object
79 80 81 |
# File 'lib/tba.rb', line 79 def get_event(event) fetch('event/' + event) end |
#get_event_awards(event) ⇒ Object
95 96 97 |
# File 'lib/tba.rb', line 95 def get_event_awards(event) fetch('event/' + event + '/awards') end |
#get_event_list(*year) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/tba.rb', line 71 def get_event_list(*year) if year[0] fetch('events/' + year) else fetch('events/') end end |
#get_event_matches(event) ⇒ Object
99 100 101 |
# File 'lib/tba.rb', line 99 def get_event_matches(event) fetch('event/' + event + '/matches') end |
#get_event_rankings(event) ⇒ Object
91 92 93 |
# File 'lib/tba.rb', line 91 def get_event_rankings(event) fetch('event/' + event + '/rankings') end |
#get_event_stats(event) ⇒ Object
87 88 89 |
# File 'lib/tba.rb', line 87 def get_event_stats(event) fetch('event/' + event + '/stats') end |
#get_event_teams(event) ⇒ Object
83 84 85 |
# File 'lib/tba.rb', line 83 def get_event_teams(event) fetch('event/' + event + '/teams') end |
#get_match(match) ⇒ Object
TODO: Make this a bit more accessible. Add automatic key generation, etc.
108 109 110 |
# File 'lib/tba.rb', line 108 def get_match(match) fetch('match/' + match) end |
#get_team(team) ⇒ Object
23 24 25 |
# File 'lib/tba.rb', line 23 def get_team(team) fetch('team/frc' + team.to_s) end |
#get_team_awards(team, *event) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/tba.rb', line 31 def get_team_awards(team, *event) if event[0] fetch('team/frc' + team.to_s + '/event/' + event[0] + '/awards') else fetch('team/frc' + team.to_s) end end |
#get_team_events(team, year) ⇒ Object
27 28 29 |
# File 'lib/tba.rb', line 27 def get_team_events(team, year) fetch('team/frc' + team + '/' + year) end |
#get_team_history_awards(team) ⇒ Object
59 60 61 |
# File 'lib/tba.rb', line 59 def get_team_history_awards(team) fetch('team/frc' + team + '/history/awards') end |
#get_team_history_districts(team) ⇒ Object
67 68 69 |
# File 'lib/tba.rb', line 67 def get_team_history_districts(team) fetch('team/frc' + team + '/history/districts') end |
#get_team_history_events(team) ⇒ Object
55 56 57 |
# File 'lib/tba.rb', line 55 def get_team_history_events(team) fetch('team/frc' + team + '/history/events') end |
#get_team_history_robots(team) ⇒ Object
63 64 65 |
# File 'lib/tba.rb', line 63 def get_team_history_robots(team) fetch('team/frc' + team + '/history/robots') end |
#get_team_matches(team, event) ⇒ Object
39 40 41 |
# File 'lib/tba.rb', line 39 def get_team_matches(team, event) fetch('team/frc' + team + '/event/' + event + '/matches') end |
#get_team_media(team, *year) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/tba.rb', line 47 def get_team_media(team, *year) if year[0] fetch('team/frc' + team.to_s + '/' + year[0].to_s + '/media') else fetch('team/frc' + team.to_s + '/media') end end |
#get_team_years(team) ⇒ Object
43 44 45 |
# File 'lib/tba.rb', line 43 def get_team_years(team) fetch('team/frc' + team + '/years_participated') end |
#get_teams(index) ⇒ Object
19 20 21 |
# File 'lib/tba.rb', line 19 def get_teams(index) fetch('teams/' + index.to_s) end |