Class: Vindetta::Decoder

Inherits:
Object
  • Object
show all
Defined in:
lib/vindetta/decoder.rb

Class Method Summary collapse

Class Method Details

.model_year(vin) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vindetta/decoder.rb', line 15

def self.model_year(vin)
  @years ||= YAML.load_file(File.expand_path("../data/vis.yaml", __FILE__))["year"]
  @alpha ||= "ABCDEFGHJKLMNPRSTUVWXYZ".chars

  tenth = vin[9]
  seventh = vin[6]

  if @alpha.include?(seventh)
    @years[tenth].last
  else
    @years[tenth].first
  end
end

.vin(vin) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/vindetta/decoder.rb', line 3

def self.vin(vin)
  {
    :plant_code => vin[PLANT_CODE_INDEX],
    :wmi => vin[WMI_RANGE],
    :check_digit => vin[CHECK_DIGIT_INDEX],
    :production_number => vin[PRODUCTION_NUMBER_RANGE],
    :model_year => model_year(vin),
  }
end