Class: Vindsl::VIN

Inherits:
Object
  • Object
show all
Defined in:
lib/vindsl/vin.rb

Instance Method Summary collapse

Constructor Details

#initialize(vin) ⇒ VIN

Returns a new instance of VIN.



6
7
8
# File 'lib/vindsl/vin.rb', line 6

def initialize(vin)
  @vin = vin.upcase
end

Instance Method Details

#countryObject



14
15
16
# File 'lib/vindsl/vin.rb', line 14

def country
  WMI.country_for @vin
end

#manufacturerObject



18
19
20
# File 'lib/vindsl/vin.rb', line 18

def manufacturer
  WMI.manufacturer_for @vin
end

#model_yearObject



22
23
24
25
26
27
# 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

#wmiObject



10
11
12
# File 'lib/vindsl/vin.rb', line 10

def wmi
  @vin[0..3]
end