lib/vindetta/generator.rb in vindetta-0.24.0 vs lib/vindetta/generator.rb in vindetta-0.25.0
- old
+ new
@@ -1,29 +1,36 @@
module Vindetta
class Generator
- def self.vin(options = {})
+ attr_reader :standard
+
+ def initialize(standard)
+ @standard = standard
+ end
+
+ def vin(options = {})
"#{wmi}#{vds}#{vis}".tap do |vin|
vin[CHECK_DIGIT_INDEX] = Calculator.check_digit(vin)
end
end
- def self.wmi(_options = {})
+ def 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")
+ "#{@wmis.sample}".rjust(standard.wmi.length, "9")
end
- def self.vds(_options = {})
- VDS_CHARACTERS.sample(VDS_LENGTH).join("")
+ def vds(_options = {})
+ characters = standard.vds.map(&:characters)
+
+ characters.map(&:sample).join
end
- def self.vis(_options = {})
- [
- MODEL_YEAR_CHARACTERS.sample,
- VIS_CHARACTERS.sample(VIS_LENGTH - 1)
- ].flatten.join("")
+ def vis(_options = {})
+ characters = standard.vis.map(&:characters)
+
+ characters.map(&:sample).join
end
end
end