Class: ErgastClient
- Inherits:
-
Object
- Object
- ErgastClient
- Defined in:
- lib/ergast_f1/ergast_client.rb
Constant Summary collapse
- BASE_URL =
"http://ergast.com/api/f1/"
Instance Method Summary collapse
- #api_get_request ⇒ Object
-
#initialize(endpoint_path) ⇒ ErgastClient
constructor
A new instance of ErgastClient.
Constructor Details
#initialize(endpoint_path) ⇒ ErgastClient
Returns a new instance of ErgastClient.
4 5 6 7 |
# File 'lib/ergast_f1/ergast_client.rb', line 4 def initialize(endpoint_path) # TODO: SUPPORT OTHER FORMATS BESIDES JSON @endpoint = BASE_URL + endpoint_path + ".json" end |
Instance Method Details
#api_get_request ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/ergast_f1/ergast_client.rb', line 9 def api_get_request c = Curl::Easy.new(@endpoint) c.connect_timeout = 60 c.timeout = 300 c.http_get() # TODO: ADD CONNECTION ERROR HANDLING return json_parse_response(c.body_str) end |