class Til::Note
Attributes
path[RW]
Public Class Methods
new(path)
click to toggle source
# File lib/til/models/note.rb, line 5 def initialize path @path = path end
Public Instance Methods
content()
click to toggle source
# File lib/til/models/note.rb, line 33 def content IO.readlines(path) end
date_modified()
click to toggle source
# File lib/til/models/note.rb, line 37 def date_modified @date_modified ||= mtime.to_date end
mtime()
click to toggle source
# File lib/til/models/note.rb, line 9 def mtime File.mtime(path) end
pretty_printed_mtime()
click to toggle source
# File lib/til/models/note.rb, line 17 def pretty_printed_mtime if date_modified == Date.today "today" elsif date_modified == (Date.today - 1) "yesterday" elsif date_modified > (Date.today - 6) mtime.strftime("%A") else mtime.strftime("%b. %-d, %Y") end end
subject()
click to toggle source
# File lib/til/models/note.rb, line 13 def subject /\/([^\/]+)\/[^\/]+$/.match(path)[1] end
title()
click to toggle source
# File lib/til/models/note.rb, line 29 def title content[0].gsub("# ","").chomp end
to_note_list()
click to toggle source
# File lib/til/models/note.rb, line 41 def to_note_list NoteList.new([self]) end