class EverExp::Notes

Public Class Methods

new(dir) click to toggle source
Calls superclass method
# File lib/ever_exp/notes.rb, line 8
def initialize dir
  group_into_notes files_in dir
  super notes_hash.values
  remove_instance_variable :@notes_hash
end

Public Instance Methods

group_by_tag() click to toggle source
# File lib/ever_exp/notes.rb, line 14
def group_by_tag
  tag_groups = Hash.new { |hash, tag| hash[tag] = [] }
  each do |note|
    note.tag_array.each do |tag|
      tag_groups[tag] << note
    end
  end
  tag_groups
end

Private Instance Methods

classify(file) click to toggle source
# File lib/ever_exp/notes.rb, line 39
def classify file
  klass = File.extname(file) == '.html' ? EverExp::Html : EverExp::Files
  klass.new file
end
files_in(dir) click to toggle source
# File lib/ever_exp/notes.rb, line 26
def files_in dir
  wildcast = File.join dir, '*'
  Dir[wildcast]
end
group_into_notes(files) click to toggle source
# File lib/ever_exp/notes.rb, line 31
def group_into_notes files
  files.each do |file|
    html_or_files = classify file
    note = notes_hash[html_or_files.name]
    note << html_or_files
  end
end
notes_hash() click to toggle source
# File lib/ever_exp/notes.rb, line 44
def notes_hash
  @notes_hash ||= Hash.new { |hash, name| hash[name] = EverExp::Note.new }
end