lib/vindetta/generator.rb in vindetta-0.25.0 vs lib/vindetta/generator.rb in vindetta-0.26.0
- old
+ new
@@ -1,36 +1,35 @@
+# frozen_string_literal: true
+
module Vindetta
class Generator
attr_reader :standard
def initialize(standard)
@standard = standard
end
- def vin(options = {})
- "#{wmi}#{vds}#{vis}".tap do |vin|
+ def vin(_options = {})
+ String.new("#{wmi}#{vds}#{vis}").tap do |vin|
vin[CHECK_DIGIT_INDEX] = Calculator.check_digit(vin)
end
end
def wmi(_options = {})
- @wmis ||= begin
- path = File.expand_path("../data/wmi.yaml", __FILE__)
- YAML.load_file(path)["wmi"].keys
- end
-
- "#{@wmis.sample}".rjust(standard.wmi.length, "9")
+ characters("wmi").map(&:sample).join
end
def vds(_options = {})
- characters = standard.vds.map(&:characters)
-
- characters.map(&:sample).join
+ characters("vds").map(&:sample).join
end
def vis(_options = {})
- characters = standard.vis.map(&:characters)
+ characters("vis").map(&:sample).join
+ end
- characters.map(&:sample).join
+ private
+
+ def characters(section)
+ standard.send(section).map { |p| p["characters"] }
end
end
end