Sha256: e306c5eef8d253bc9d71dcb4c2801401fa4e345155dd12e8bfb9448497d7f802

Contents?: true

Size: 669 Bytes

Versions: 3

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

module Vindetta
  class Generator
    attr_reader :standard

    def initialize(standard)
      @standard = standard
    end

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

    def wmi(_options = {})
      characters("wmi").map(&:sample).join
    end

    def vds(_options = {})
      characters("vds").map(&:sample).join
    end

    def vis(_options = {})
      characters("vis").map(&:sample).join
    end

    private

    def characters(section)
      standard.send(section).map { |p| p["characters"] }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vindetta-0.28.0 lib/vindetta/generator.rb
vindetta-0.27.0 lib/vindetta/generator.rb
vindetta-0.26.0 lib/vindetta/generator.rb