class Vindetta::Decoder
Constants
- ALPHA
- BASE_MODEL_YEAR
- NUMERIC
Attributes
standard[R]
Public Class Methods
new(standard)
click to toggle source
# File lib/vindetta/decoder.rb, line 11 def initialize(standard) @standard = standard end
Public Instance Methods
vin(vin)
click to toggle source
# File lib/vindetta/decoder.rb, line 15 def 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), region: region(vin) } end
Private Instance Methods
model_year(vin)
click to toggle source
# File lib/vindetta/decoder.rb, line 35 def model_year(vin) position = standard.vis.detect { |p| p["name"] === "model_year" } characters = position["characters"] index = characters.find_index { |c| c == vin[9] } if ALPHA.include?(vin[6]) BASE_MODEL_YEAR + index + 30 else BASE_MODEL_YEAR + index end end
region(vin)
click to toggle source
# File lib/vindetta/decoder.rb, line 28 def region(vin) character = vin[0] position = standard.wmi.detect { |p| p["name"] == "region" } position["mapping"][character] end