class Til::NoteDisplayer

Constants

HIGHLIGHT_COLORS

Attributes

notes[RW]

Public Class Methods

new(notes) click to toggle source
# File lib/til/services/note_displayer.rb, line 15
def initialize notes
  @notes = notes.to_note_list
end

Public Instance Methods

list() click to toggle source
# File lib/til/services/note_displayer.rb, line 26
def list
  subjects_seen = Array.new
  longest_subject_length = notes.sort_by{|note| note.subject.length}.last.subject.length
  notes.each do |note|
    subjects_seen.push(note.subject) if !subjects_seen.include?(note.subject)
    color_index = subjects_seen.index(note.subject) % HIGHLIGHT_COLORS.length
    color = HIGHLIGHT_COLORS[color_index]
    spacing = " " * (longest_subject_length - note.subject.length)
    puts note.subject.colorize(color) + ": " + spacing + note.title.bold + " (" + note.pretty_printed_mtime + ")"
  end
end
print() click to toggle source