Class: FluShot::Storage::Memory
- Inherits:
-
Object
- Object
- FluShot::Storage::Memory
- Defined in:
- lib/flu_shot/storage/memory.rb
Instance Method Summary collapse
- #add(prescription_name, vaccines) ⇒ Object
- #get(prescription_name) ⇒ Object
-
#initialize ⇒ Memory
constructor
A new instance of Memory.
Constructor Details
#initialize ⇒ Memory
Returns a new instance of Memory.
4 5 6 |
# File 'lib/flu_shot/storage/memory.rb', line 4 def initialize @storage = {} end |
Instance Method Details
#add(prescription_name, vaccines) ⇒ Object
8 9 10 11 12 |
# File 'lib/flu_shot/storage/memory.rb', line 8 def add(prescription_name, vaccines) @storage[prescription_name] ||= [] vaccines = [vaccines] unless vaccines.is_a?(Array) @storage[prescription_name] = vaccines end |
#get(prescription_name) ⇒ Object
14 15 16 |
# File 'lib/flu_shot/storage/memory.rb', line 14 def get(prescription_name) @storage[prescription_name] || [] end |