Class: VinValidator::Wmi

Inherits:
BaseModel show all
Defined in:
lib/vin_validator/wmi.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

all

Constructor Details

#initialize(id:, wmi:, maker_id:, wmi_suffix: nil) ⇒ Wmi

:nodoc:



40
41
42
43
44
45
46
47
# File 'lib/vin_validator/wmi.rb', line 40

def initialize(id:, wmi:, maker_id:, wmi_suffix: nil)
  super

  @id = id
  @maker_id = maker_id
  @wmi = wmi
  @wmi_suffix = wmi_suffix
end

Instance Attribute Details

#idInteger

Returns:

  • (Integer)


31
32
33
# File 'lib/vin_validator/wmi.rb', line 31

def id
  @id
end

#maker_idInteger

Returns:

  • (Integer)


37
38
39
# File 'lib/vin_validator/wmi.rb', line 37

def maker_id
  @maker_id
end

#wmiString

Returns:

  • (String)


33
34
35
# File 'lib/vin_validator/wmi.rb', line 33

def wmi
  @wmi
end

#wmi_suffixString, Nil

Returns:

  • (String, Nil)


35
36
37
# File 'lib/vin_validator/wmi.rb', line 35

def wmi_suffix
  @wmi_suffix
end

Class Method Details

.find(id) ⇒ VinValidator::Wmi

Finds the wmi with the given ‘id`

Returns:



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

def find(id)
  all.fetch(id.to_s)
end

.where(wmi:) ⇒ Array<VinValidator::Wmi>

Finds the wmi(s) with the given ‘wmi`

Returns:



18
19
20
# File 'lib/vin_validator/wmi.rb', line 18

def where(wmi:)
  all.values.select { |w| w.wmi == wmi }
end

Instance Method Details

#makerVinValidator::Maker

Finds the corresponding maker

Returns:



53
54
55
# File 'lib/vin_validator/wmi.rb', line 53

def maker
  @maker ||= VinValidator::Maker.find(maker_id)
end