class RDW::CarInfo

Public Class Methods

new(license_plate) click to toggle source
# File lib/rdw.rb, line 9
def initialize(license_plate)
  @license_plate = license_plate
  perform_request!
end

Public Instance Methods

BPM() click to toggle source
# File lib/rdw.rb, line 22
def BPM
  parse("BPM").to_i
end
brand() click to toggle source
# File lib/rdw.rb, line 54
def brand
  parse("Merk")
end
co2_combined() click to toggle source
# File lib/rdw.rb, line 42
def co2_combined
  parse("CO2uitstootgecombineerd").to_f
end
color() click to toggle source
# File lib/rdw.rb, line 46
def color
  parse("Eerstekleur")
end
cylinder_capacity() click to toggle source
# File lib/rdw.rb, line 38
def cylinder_capacity
  parse("Cilinderinhoud").to_f
end
energy_label() click to toggle source
# File lib/rdw.rb, line 58
def energy_label
  parse("Zuinigheidslabel")
end
fuel_efficiency_city() click to toggle source
# File lib/rdw.rb, line 30
def fuel_efficiency_city
  parse("Brandstofverbruikstad").to_f
end
fuel_efficiency_combined() click to toggle source
# File lib/rdw.rb, line 34
def fuel_efficiency_combined
  parse("Brandstofverbruikgecombineerd").to_f
end
fuel_efficiency_main_road() click to toggle source
# File lib/rdw.rb, line 26
def fuel_efficiency_main_road
  parse("Brandstofverbruikbuitenweg").to_f
end
fuel_type() click to toggle source
# File lib/rdw.rb, line 50
def fuel_type
  parse("Hoofdbrandstof")
end
inspect() click to toggle source
# File lib/rdw.rb, line 62
def inspect
  "<RDW::CarInfo license_plate:'#{@license_plate}' brand:'#{brand}' fuel_type:'#{fuel_type}'>"
end
number_of_cylinders() click to toggle source
# File lib/rdw.rb, line 14
def number_of_cylinders
  parse("Aantalcilinders").to_i
end
number_of_seats() click to toggle source
# File lib/rdw.rb, line 18
def number_of_seats
  parse("Aantalzitplaatsen").to_i
end

Private Instance Methods

parse(attribute_name) click to toggle source
# File lib/rdw.rb, line 68
def parse(attribute_name)
  @xml.xpath("//d:#{attribute_name.to_s}").text
end
perform_request!() click to toggle source
# File lib/rdw.rb, line 72
def perform_request!
  response = Net::HTTP.get_response(URI("https://api.datamarket.azure.com/Data.ashx/opendata.rdw/VRTG.Open.Data/v1/KENT_VRTG_O_DAT('#{@license_plate}')"))
  @xml = Nokogiri::XML(response.body)
end