Class: VinValidator::Wmi
- Defined in:
- lib/vin_validator/wmi.rb
Instance Attribute Summary collapse
Class Method Summary collapse
-
.find(id) ⇒ VinValidator::Wmi
Finds the wmi with the given ‘id`.
-
.where(wmi:) ⇒ Array<VinValidator::Wmi>
Finds the wmi(s) with the given ‘wmi`.
Instance Method Summary collapse
-
#initialize(id:, wmi:, maker_id:, wmi_suffix: nil) ⇒ Wmi
constructor
:nodoc:.
-
#maker ⇒ VinValidator::Maker
Finds the corresponding maker.
Methods inherited from BaseModel
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
#id ⇒ Integer
31 32 33 |
# File 'lib/vin_validator/wmi.rb', line 31 def id @id end |
#maker_id ⇒ Integer
37 38 39 |
# File 'lib/vin_validator/wmi.rb', line 37 def maker_id @maker_id end |
#wmi ⇒ String
33 34 35 |
# File 'lib/vin_validator/wmi.rb', line 33 def wmi @wmi end |
#wmi_suffix ⇒ 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`
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`
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
#maker ⇒ VinValidator::Maker
Finds the corresponding maker
53 54 55 |
# File 'lib/vin_validator/wmi.rb', line 53 def maker @maker ||= VinValidator::Maker.find(maker_id) end |