Class: Vindetta::Generator

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

Constant Summary collapse

WMI_CHARACTERS =
"0123456789ABCDEFGHJKLMNPRSTUVWXYZ".chars
VDS_CHARACTERS =
"0123456789ABCDEFGHJKLMNPRSTUVWXYZ".chars
VIS_CHARACTERS =
"0123456789ABCDEFGHJKLMNPRSTUVWXYZ".chars

Class Method Summary collapse

Class Method Details

.vds(_options = {}) ⇒ Object



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

def self.vds(_options = {})
  VDS_CHARACTERS.sample(6).join("")
end

.vin(options = {}) ⇒ Object



7
8
9
10
11
# File 'lib/vindetta/generator.rb', line 7

def self.vin(options = {})
  "#{wmi}#{vds}#{vis}".tap do |vin|
    vin[8] = Calculator.check_digit(vin)
  end
end

.vis(_options = {}) ⇒ Object

One consistent element of the VIS is the 10th digit, which is required worldwide to encode the model year of the vehicle. Besides the three letters that are not allowed in the VIN itself (I, O and Q), the letters U and Z and the digit 0 are not used for the model year code. The year code is the model year for the vehicle.



29
30
31
# File 'lib/vindetta/generator.rb', line 29

def self.vis(_options = {})
  VIS_CHARACTERS.sample(8).join("")
end

.wmi(_options = {}) ⇒ Object



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

def self.wmi(_options = {})
  WMI_CHARACTERS.sample(3).join("")
end