lib/vindetta/validator.rb in vindetta-0.24.0 vs lib/vindetta/validator.rb in vindetta-0.25.0
- old
+ new
@@ -1,28 +1,34 @@
module Vindetta
class Validator
- def self.vin(vin)
- return false unless vin.length == Vindetta::VIN_LENGTH
+ attr_reader :standard
- Calculator.check_digit(vin) == Decoder.vin(vin)[:check_digit]
+ def initialize(standard)
+ @standard = standard
+ end
+
+ def vin(vin)
+ return false unless vin.length == standard::LENGTH
+
+ Calculator.check_digit(vin) == Decoder.new(Vindetta::Standard::ISO3779).vin(vin)[:check_digit]
rescue Calculator::InvalidCharacterError
false
end
- def self.wmi(wmi)
- return false unless wmi.length == Vindetta::WMI_LENGTH
+ def wmi(wmi)
+ return false unless wmi.length == standard.wmi.length
true
end
- def self.vds(vds)
- return false unless vds.length == Vindetta::VDS_LENGTH
+ def vds(vds)
+ return false unless vds.length == standard.vds.length
true
end
- def self.vis(vis)
- return false unless vis.length == Vindetta::VIS_LENGTH
+ def vis(vis)
+ return false unless vis.length == standard.vis.length
true
end
end
end