Class: WorkGuide::Storage
- Inherits:
-
Object
- Object
- WorkGuide::Storage
- Defined in:
- lib/work_guide/storage.rb
Instance Method Summary collapse
-
#initialize(name) ⇒ Storage
constructor
A new instance of Storage.
- #load ⇒ Object
- #store(json) ⇒ Object
Constructor Details
#initialize(name) ⇒ Storage
Returns a new instance of Storage.
7 8 9 |
# File 'lib/work_guide/storage.rb', line 7 def initialize(name) @path = work_guide_dir.join(name.to_s) end |
Instance Method Details
#load ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/work_guide/storage.rb', line 11 def load if @path.exist? JSON.parse(@path.read) else [] end end |
#store(json) ⇒ Object
19 20 21 22 23 |
# File 'lib/work_guide/storage.rb', line 19 def store(json) @path.open('w') do |f| f.puts json end end |