Sha256: f7654362f64c5d86aa9b6c96c41f4d813cad0192384427ffa3da4733fab1b706

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

module Vindetta
  class Validator
    attr_reader :standard

    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 wmi(wmi)
      return false unless wmi.length == standard.wmi.length

      true
    end

    def vds(vds)
      return false unless vds.length == standard.vds.length

      true
    end

    def vis(vis)
      return false unless vis.length == standard.vis.length

      true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.25.0 lib/vindetta/validator.rb