Class: Vindetta::Decoder

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

Defined Under Namespace

Modules: DSL Classes: Result

Constant Summary collapse

CHECK_DIGIT_INDEX =
8

Class Method Summary collapse

Class Method Details

.check_digit(vin) ⇒ Object



17
18
19
# File 'lib/vindetta/decoder.rb', line 17

def self.check_digit(vin)
  vin[CHECK_DIGIT_INDEX]
end

.plant_code(vin) ⇒ Object



13
14
15
# File 'lib/vindetta/decoder.rb', line 13

def self.plant_code(vin)
  vin[10]
end

.production_number(vin) ⇒ Object



42
43
44
# File 'lib/vindetta/decoder.rb', line 42

def self.production_number(vin)
  vin[11..16]
end

.vds(vin, options = {}) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/vindetta/decoder.rb', line 25

def self.vds(vin, options = {})
  defaults = { check_digit: true }
  options = defaults.merge(options)

  vin[3..CHECK_DIGIT_INDEX].tap do |vds|
    vds.chop! unless options[:check_digit]
  end
end

.vin(vin) ⇒ Object



9
10
11
# File 'lib/vindetta/decoder.rb', line 9

def self.vin(vin)
  Result.new(Api.decode(vin)["Results"])
end

.vis(vin) ⇒ Object



38
39
40
# File 'lib/vindetta/decoder.rb', line 38

def self.vis(vin)
  vin[9..16]
end

.wmi(vin) ⇒ Object



21
22
23
# File 'lib/vindetta/decoder.rb', line 21

def self.wmi(vin)
  vin[0..2]
end

.year(vin) ⇒ Object



34
35
36
# File 'lib/vindetta/decoder.rb', line 34

def self.year(vin)
  vin(vin).year
end