Sha256: 4dba4d0571fa5fdfb978eddc9441c78ad56dfcd48c9316f068ce11eab53ceb84

Contents?: true

Size: 666 Bytes

Versions: 1

Compression:

Stored size: 666 Bytes

Contents

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

    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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.24.0 lib/vindetta/generator.rb