Class: MorningPages::Folder
- Inherits:
-
Object
- Object
- MorningPages::Folder
- Defined in:
- lib/morning-pages/folder.rb
Instance Method Summary collapse
- #get_words_for(path) ⇒ Object
-
#initialize(options = {}) ⇒ Folder
constructor
A new instance of Folder.
- #today_path ⇒ Object
- #todays_words ⇒ Object
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( = {}) @dir = [: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_path ⇒ Object
14 15 16 |
# File 'lib/morning-pages/folder.rb', line 14 def today_path File.([@dir, Time.now.strftime("%Y\-%m\-%d")].join('/')) end |
#todays_words ⇒ Object
10 11 12 |
# File 'lib/morning-pages/folder.rb', line 10 def todays_words get_words_for(today_path) end |