Class: Trundle::TextStore
- Inherits:
-
Object
- Object
- Trundle::TextStore
- Defined in:
- lib/trundle/text_store.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(path) ⇒ TextStore
constructor
A new instance of TextStore.
- #write ⇒ Object
Constructor Details
#initialize(path) ⇒ TextStore
Returns a new instance of TextStore.
4 5 6 |
# File 'lib/trundle/text_store.rb', line 4 def initialize(path) @path = path end |
Instance Attribute Details
#content ⇒ Object
8 9 10 11 12 |
# File 'lib/trundle/text_store.rb', line 8 def content @content ||= File.read(@path) rescue @content = '' end |
Instance Method Details
#write ⇒ Object
14 15 16 17 18 |
# File 'lib/trundle/text_store.rb', line 14 def write File.open(@path, 'w') do |file| file.write(content) end end |