class Todo::Src::File
Attributes
mode[R]
path[R]
Public Class Methods
new(path, opts = {})
click to toggle source
# File lib/todo/src/file.rb, line 6 def initialize(path, opts = {}) @path = path @mode = opts[:mode] || 'w+' end
Public Instance Methods
exists?()
click to toggle source
# File lib/todo/src/file.rb, line 11 def exists? ::File.exists?(path) end
read()
click to toggle source
# File lib/todo/src/file.rb, line 15 def read exists? ? ::File.readlines(path).map(&:rstrip) : [] end
write(lines)
click to toggle source
# File lib/todo/src/file.rb, line 19 def write(lines) ::File.open(path, mode) { |f| f.puts(lines.join("\n")) } end