Sha256: e8eccdf3220b1fd2516d1d3da28ffe0698d5dd30c876b7233de3c816cfee5ca5

Contents?: true

Size: 788 Bytes

Versions: 11

Compression:

Stored size: 788 Bytes

Contents

module Vindetta
  class Vin
    class Wmi
      DATA_PATH = File.expand_path("../../data/wmi.yaml", __FILE__)

      def initialize(vin)
        @vin = vin
      end

      def name
        @name ||= self.class.data["wmi"][value]
      end

      alias eql? ==

      def value
        @vin[0..2].join("")
      end

      def region
        @name ||= begin
          regions = self.class.data["region"] # TODO: Pull this out into private method

          regions.detect do |key, characters_for_region|
            break key if characters_for_region.include?(value[0])
          end
        end
      end

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

      def self.data
        @data ||= YAML.load_file(DATA_PATH)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vindetta-0.19.0 lib/vindetta/vin/wmi.rb
vindetta-0.17.1 lib/vindetta/vin/wmi.rb
vindetta-0.17.0 lib/vindetta/vin/wmi.rb
vindetta-0.16.0 lib/vindetta/vin/wmi.rb
vindetta-0.15.0 lib/vindetta/vin/wmi.rb
vindetta-0.14.0 lib/vindetta/vin/wmi.rb
vindetta-0.13.0 lib/vindetta/vin/wmi.rb
vindetta-0.12.0 lib/vindetta/vin/wmi.rb
vindetta-0.11.0 lib/vindetta/vin/wmi.rb
vindetta-0.10.0 lib/vindetta/vin/wmi.rb
vindetta-0.9.0 lib/vindetta/vin/wmi.rb