Class: Trundle::InfoStore
- Inherits:
-
Object
- Object
- Trundle::InfoStore
- Defined in:
- lib/trundle/info_store.rb
Instance Method Summary collapse
- #content ⇒ Object
- #content=(value) ⇒ Object
-
#initialize(path) ⇒ InfoStore
constructor
A new instance of InfoStore.
- #write ⇒ Object
Constructor Details
#initialize(path) ⇒ InfoStore
Returns a new instance of InfoStore.
4 5 6 |
# File 'lib/trundle/info_store.rb', line 4 def initialize(path) @path = path end |
Instance Method Details
#content ⇒ Object
12 13 14 15 16 |
# File 'lib/trundle/info_store.rb', line 12 def content @content ||= JSON.parse(File.read(@path)) rescue Errno::ENOENT @content = {} end |
#content=(value) ⇒ Object
8 9 10 |
# File 'lib/trundle/info_store.rb', line 8 def content=(value) @content = value end |
#write ⇒ Object
18 19 20 21 22 |
# File 'lib/trundle/info_store.rb', line 18 def write File.open(@path, 'w') do |file| file.write(JSON.pretty_generate(content)) end end |