class Vindsl::VIN

Public Class Methods

new(vin) click to toggle source
# File lib/vindsl/vin.rb, line 6
def initialize(vin)
  @vin = vin.upcase
end

Public Instance Methods

country() click to toggle source
# File lib/vindsl/vin.rb, line 14
def country
  WMI.country_for @vin
end
manufacturer() click to toggle source
# File lib/vindsl/vin.rb, line 18
def manufacturer
  WMI.manufacturer_for @vin
end
model_year() click to toggle source
# File lib/vindsl/vin.rb, line 22
def model_year
  year_character = position(10)
  base = pre_2009? ? 1980 : 2010

  base + Vindsl::Alphabet::ALPHABET_FOR_YEARS.index(year_character)
end
wmi() click to toggle source
# File lib/vindsl/vin.rb, line 10
def wmi
  @vin[0..3]
end

Private Instance Methods

position(n) click to toggle source
# File lib/vindsl/vin.rb, line 30
def position(n)
  @vin[n-1]
end
pre_2009?() click to toggle source
# File lib/vindsl/vin.rb, line 34
def pre_2009?
  position(7) =~ /\d/
end