Sha256: 633a608b23377df02476823875c148b4ba8d7693cad2d14295775d0d69bd81ef

Contents?: true

Size: 979 Bytes

Versions: 1

Compression:

Stored size: 979 Bytes

Contents

require "active_support"
require "active_model"

module Vindetta
  class Vin
    include ActiveModel::Validations
    include Enumerable

    def each(&block)
      @value.chars(&block)
    end

    def [](index)
      each[index]
    end

    attr_reader :value

    validates_with Validator

    def initialize(value)
      @value = value
    end

    alias eql? ==

    def ==(other)
      self.class == other.class && value == other.value
    end

    def check_digit
      value[8]
    end

    def year
      vis.year
    end

    ##
    # World Manufacturer Identity
    #
    def wmi
      @wmi ||= Wmi.new(self)
    end

    # #
    # Vehicle Descriptor Section
    #
    def vds
      @vds ||= Vds.new(self)
    end

    ##
    # Vehicle Identifier Section
    #
    def vis
      @vis ||= Vis.new(self)
    end

    def model_year
      value[9]
    end

    def manufacturing_plant
      value[10]
    end

    def serial_number
      value[11..16]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vindetta-0.8.0 lib/vindetta/vin.rb