class DailyLog::Entry
One Daily Log journal Entry
Constants
- TEMPLATE_PATH
Default path for the daily entry Markdown template
Attributes
Public Class Methods
Public Instance Methods
open()
click to toggle source
print()
click to toggle source
Print the contents of this Entry
to STDOUT. If no entry exists, print a warning.
# 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
Private Instance Methods
ensure!()
click to toggle source
# File lib/daily_log/entry.rb, line 80 def ensure! return if exists? FileUtils.mkdir_p(pathname.dirname) template = ERB.new File.read(template_path) File.open(pathname.to_s, "wb") do |file| file.write template.result(binding) end end
exists?()
click to toggle source
# File lib/daily_log/entry.rb, line 76 def exists? File.exist?(pathname) end
file()
click to toggle source
# File lib/daily_log/entry.rb, line 56 def file @file ||= File.open(pathname, 'r') end
local_template_exists?()
click to toggle source
# File lib/daily_log/entry.rb, line 72 def local_template_exists? File.exist?(local_template_path) end
local_template_path()
click to toggle source
# File lib/daily_log/entry.rb, line 60 def local_template_path "./#{Pathname.dirname}/templates.md.erb" end
open_in_editor()
click to toggle source
# File lib/daily_log/entry.rb, line 52 def open_in_editor exec("$EDITOR -w #{pathname}") end
template_path()
click to toggle source
# File lib/daily_log/entry.rb, line 64 def template_path if local_template_exists? local_template_path else TEMPLATE_PATH end end