Sha256: cab6cfb49901da134c66e0e9180af4a9ad132164ca7462f318d47ae9190feb4d

Contents?: true

Size: 666 Bytes

Versions: 2

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 = {})
      [
        VIS_CHARACTERS.sample(VIS_LENGTH - 1),
        MODEL_YEAR_CHARACTERS.sample
      ].flatten.join("")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vindetta-0.23.0 lib/vindetta/generator.rb
vindetta-0.22.0 lib/vindetta/generator.rb