Class: DailyLog::Entry
- Inherits:
-
Object
- Object
- DailyLog::Entry
- Defined in:
- lib/daily_log/entry.rb
Overview
One Daily Log journal Entry
Constant Summary collapse
- TEMPLATE_PATH =
Default path for the daily entry Markdown template
File.join(File.dirname(__FILE__), '..', '..', 'lib/templates/daily_log/entry.md.erb')
Instance Attribute Summary collapse
-
#day ⇒ Object
readonly
The Day this Entry is for.
-
#pathname ⇒ Object
readonly
The Pathname of the file to the Entry.
Instance Method Summary collapse
-
#initialize(day) ⇒ Entry
constructor
Create a new Entry.
-
#open ⇒ Object
Open the Entry file in the text editor.
-
#print ⇒ Object
Print the contents of this Entry to STDOUT.
Constructor Details
Instance Attribute Details
#day ⇒ Object (readonly)
The Day this Entry is for
12 13 14 |
# File 'lib/daily_log/entry.rb', line 12 def day @day end |
#pathname ⇒ Object (readonly)
The Pathname of the file to the Entry
16 17 18 |
# File 'lib/daily_log/entry.rb', line 16 def pathname @pathname end |
Instance Method Details
#open ⇒ Object
Open the Entry file in the text editor. If one doens’t already exist, create it for this Day
45 46 47 48 |
# File 'lib/daily_log/entry.rb', line 45 def open ensure! open_in_editor end |
#print ⇒ Object
Print the contents of this Entry to STDOUT. If no entry exists, print a warning.
35 36 37 38 39 40 41 |
# File 'lib/daily_log/entry.rb', line 35 def print if exists? puts file.read else puts "No file exists for date: #{@day}" end end |