class NlGasStations::GasStations

Public Class Methods

find_stations(postal_code, fuel_type, distance = 5) click to toggle source

Find gas stations by postal code, fuel type and an optional distance. The default distance is 5. fuel_type must be one of the hash keys returned by GasStations.fuel_types

# File lib/nl_gas_stations/gas_stations.rb, line 10
def self.find_stations(postal_code, fuel_type, distance = 5)
  distance = 5 unless [5, 10, 15, 25].include?(distance)
  fuel_type = self.fuel_types[fuel_type]
  Scraper.scrape({'postcode' => postal_code, 'plaats' => '', 'afstand' => distance, 'brandstof' => fuel_type, 'zoeken' => 'Zoeken'})
end
fuel_types() click to toggle source

Return the valid fuel types that can be search on with the GasStations.find_stations method. The hash keys must be used in the GasStations.find_stations method.

# File lib/nl_gas_stations/gas_stations.rb, line 19
def self.fuel_types
  {diesel: 'Diesel', euro_95: 'Euro 95', lpg: 'LPG', cng: 'CNG'}
end