Sha256: 58f3d42a02496119adff2ffdeb30ae263442e5fca96610d0cdf413d9a0484d3e

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 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.21.0 lib/vindetta/generator.rb
vindetta-0.20.0 lib/vindetta/generator.rb