Class: MotoRecall::Recall
- Inherits:
-
Object
- Object
- MotoRecall::Recall
- Defined in:
- lib/moto_recall/recall.rb
Constant Summary collapse
- KEYS =
i( type nhtsa_number oem_number date title description safety_risk remedy status notes )
Instance Method Summary collapse
-
#initialize(hash) ⇒ Recall
constructor
A new instance of Recall.
- #keys ⇒ Object
- #to_h ⇒ Object
- #to_json ⇒ Object
- #values ⇒ Object
Constructor Details
#initialize(hash) ⇒ Recall
Returns a new instance of Recall.
18 19 20 21 22 |
# File 'lib/moto_recall/recall.rb', line 18 def initialize(hash) KEYS.each do |key| instance_variable_set("@#{key}", hash[key]) end end |
Instance Method Details
#keys ⇒ Object
32 33 34 |
# File 'lib/moto_recall/recall.rb', line 32 def keys KEYS end |
#to_h ⇒ Object
28 29 30 |
# File 'lib/moto_recall/recall.rb', line 28 def to_h KEYS.reduce({}) { |h, k| h[k] = send(k); h } end |
#to_json ⇒ Object
24 25 26 |
# File 'lib/moto_recall/recall.rb', line 24 def to_json to_h.to_json end |
#values ⇒ Object
36 37 38 |
# File 'lib/moto_recall/recall.rb', line 36 def values KEYS.map { |k| send(k) } end |