Class: ErgastClient

Inherits:
Object
  • Object
show all
Defined in:
lib/ergast_f1/ergast_client.rb

Constant Summary collapse

BASE_URL =
"http://ergast.com/api/f1/"

Instance Method Summary collapse

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_requestObject



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