Class: ErgastF1::Race
- Inherits:
-
Object
- Object
- ErgastF1::Race
- Defined in:
- lib/ergast_f1/race.rb
Constant Summary collapse
- STATUS_TABLE =
{"Finished" => "1", "Disqualified" => "2", "Accident" => "3", "Collision" => "4", "Engine" => "5", "Gearbox" => "6", "Transmission" => "7", "Clutch" => "8", "Hydraulics" => "9", "Electrical" => "10", "Spun" => "20", "Radiator" => "21", "Suspension" => "22", "Brakes" => "23", "Differential" => "24", "Overheating" => "25", "Mechanical" => "26", "Tyre" => "27", "Driver Seat" => "28", "Puncture" => "29", "Driveshaft" => "30" }
Instance Method Summary collapse
- #constructor_result(constructor_name) ⇒ Object
- #driver_result(driver_name) ⇒ Object
- #finishing_status(status) ⇒ Object
- #grid_position(position) ⇒ Object
-
#initialize(year: nil, circuit: nil, round: nil) ⇒ Race
constructor
A new instance of Race.
- #laptime_ranking(position = nil) ⇒ Object
- #result ⇒ Object
Constructor Details
#initialize(year: nil, circuit: nil, round: nil) ⇒ Race
Returns a new instance of Race.
26 27 28 29 30 |
# File 'lib/ergast_f1/race.rb', line 26 def initialize(year: nil, circuit: nil, round: nil) @year = year || Time.now.year @circuit = circuit @round = round end |
Instance Method Details
#constructor_result(constructor_name) ⇒ Object
36 37 38 |
# File 'lib/ergast_f1/race.rb', line 36 def constructor_result(constructor_name) race_data(race_path + "/constructors/#{constructor_name}/results") end |
#driver_result(driver_name) ⇒ Object
40 41 42 |
# File 'lib/ergast_f1/race.rb', line 40 def driver_result(driver_name) race_data(race_path + "/drivers/#{driver_name}/results") end |
#finishing_status(status) ⇒ Object
48 49 50 51 |
# File 'lib/ergast_f1/race.rb', line 48 def finishing_status(status) finishing_status = resolve_finishing_status(status) race_data(race_path + "/status/#{finishing_status}/results") end |
#grid_position(position) ⇒ Object
44 45 46 |
# File 'lib/ergast_f1/race.rb', line 44 def grid_position(position) race_data(race_path + "/grid/#{position}/results") end |
#laptime_ranking(position = nil) ⇒ Object
53 54 55 56 |
# File 'lib/ergast_f1/race.rb', line 53 def laptime_ranking(position=nil) raise BadQuery, "Fastest lap data isn't available for races before 2004" if @year < 2004 race_data(race_path + "/fastest/#{position}/results") end |
#result ⇒ Object
32 33 34 |
# File 'lib/ergast_f1/race.rb', line 32 def result race_data(race_path + "/results") end |