Class: Trundle::TextStore

Inherits:
Object
  • Object
show all
Defined in:
lib/trundle/text_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject



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

#writeObject



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