Class: MorningPages::Folder

Inherits:
Object
  • Object
show all
Defined in:
lib/morning-pages/folder.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Folder

Returns a new instance of Folder.



3
4
5
6
7
8
# File 'lib/morning-pages/folder.rb', line 3

def initialize(options = {})
  @dir = options[:dir]
  if (@dir && !File.exists?(@dir))
    FileUtils.mkdir_p(@dir)
  end
end

Instance Method Details

#get_words_for(path) ⇒ Object



18
19
20
# File 'lib/morning-pages/folder.rb', line 18

def get_words_for(path)
  (File.exists?(path) ? File.read(path) : "").split(" ")
end

#today_pathObject



14
15
16
# File 'lib/morning-pages/folder.rb', line 14

def today_path
  File.expand_path([@dir, Time.now.strftime("%Y\-%m\-%d")].join('/'))
end

#todays_wordsObject



10
11
12
# File 'lib/morning-pages/folder.rb', line 10

def todays_words
  get_words_for(today_path)
end