Class: Vindetta::Validator
- Inherits:
-
Object
- Object
- Vindetta::Validator
- Defined in:
- lib/vindetta/validator.rb
Instance Attribute Summary collapse
-
#standard ⇒ Object
readonly
Returns the value of attribute standard.
Instance Method Summary collapse
-
#initialize(standard) ⇒ Validator
constructor
A new instance of Validator.
- #vds(vds) ⇒ Object
- #vin(vin) ⇒ Object
- #vis(vis) ⇒ Object
- #wmi(wmi) ⇒ Object
Constructor Details
#initialize(standard) ⇒ Validator
Returns a new instance of Validator.
7 8 9 |
# File 'lib/vindetta/validator.rb', line 7 def initialize(standard) @standard = standard end |
Instance Attribute Details
#standard ⇒ Object (readonly)
Returns the value of attribute standard.
5 6 7 |
# File 'lib/vindetta/validator.rb', line 5 def standard @standard end |
Instance Method Details
#vds(vds) ⇒ Object
23 24 25 |
# File 'lib/vindetta/validator.rb', line 23 def vds(vds) vds.length == standard.vds.length end |
#vin(vin) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/vindetta/validator.rb', line 11 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 |
#vis(vis) ⇒ Object
27 28 29 |
# File 'lib/vindetta/validator.rb', line 27 def vis(vis) vis.length == standard.vis.length end |
#wmi(wmi) ⇒ Object
19 20 21 |
# File 'lib/vindetta/validator.rb', line 19 def wmi(wmi) wmi.length == standard.wmi.length end |