Class: Vindetta::Generator

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

Class Method Summary collapse

Class Method Details

.vds(_options = {}) ⇒ Object



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

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

.vin(options = {}) ⇒ Object



3
4
5
6
7
# File 'lib/vindetta/generator.rb', line 3

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

.vis(_options = {}) ⇒ Object



22
23
24
25
26
27
# File 'lib/vindetta/generator.rb', line 22

def self.vis(_options = {})
  [
    VIS_CHARACTERS.sample(VIS_LENGTH - 1),
    MODEL_YEAR_CHARACTERS.sample
  ].flatten.join("")
end

.wmi(_options = {}) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/vindetta/generator.rb', line 9

def self.wmi(_options = {})
  @wmis ||= begin
    path = File.expand_path("../data/wmi.yaml", __FILE__)
    YAML.load_file(path)["wmi"].keys
  end

  "#{@wmis.sample}".rjust(WMI_LENGTH, "9")
end