Class: DailyLog::Entry

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(day) ⇒ Entry

Create a new Entry

day - The Day we’re creating a new Entry for



28
29
30
31
# File 'lib/daily_log/entry.rb', line 28

def initialize(day)
  @day = day
  @pathname = Pathname.new(day.date)
end

Instance Attribute Details

#dayObject (readonly)

The Day this Entry is for



12
13
14
# File 'lib/daily_log/entry.rb', line 12

def day
  @day
end

#pathnameObject (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

#openObject

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 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