Class: Vindetta::Vin::Wmi

Inherits:
Object
  • Object
show all
Defined in:
lib/vindetta/vin/wmi.rb

Constant Summary collapse

DATA_PATH =
File.expand_path("../../data/wmi.yaml", __FILE__)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vin) ⇒ Wmi

Returns a new instance of Wmi.



6
7
8
# File 'lib/vindetta/vin/wmi.rb', line 6

def initialize(vin)
  @vin = vin
end

Class Method Details

.dataObject



34
35
36
# File 'lib/vindetta/vin/wmi.rb', line 34

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

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/vindetta/vin/wmi.rb', line 30

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

#eql?Object



14
# File 'lib/vindetta/vin/wmi.rb', line 14

alias eql? ==

#nameObject



10
11
12
# File 'lib/vindetta/vin/wmi.rb', line 10

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

#regionObject



20
21
22
23
24
25
26
27
28
# File 'lib/vindetta/vin/wmi.rb', line 20

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

#valueObject



16
17
18
# File 'lib/vindetta/vin/wmi.rb', line 16

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