Class: Til::Directory

Inherits:
Object
  • Object
show all
Defined in:
lib/til/directory.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subject = nil) ⇒ Directory

Returns a new instance of Directory.



7
8
9
10
11
12
13
# File 'lib/til/directory.rb', line 7

def initialize(subject=nil)
  if subject
    @path = Settings.load.directory + "/#{subject}/*.md"
  else
    @path = Settings.load.directory + "/**/*.md"
  end
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/til/directory.rb', line 5

def path
  @path
end

Class Method Details

.for(subject) ⇒ Object



19
20
21
# File 'lib/til/directory.rb', line 19

def self.for(subject)
  self.new(subject)
end

.rootObject



15
16
17
# File 'lib/til/directory.rb', line 15

def self.root
  self.new
end

Instance Method Details

#notesObject



23
24
25
26
27
28
29
# File 'lib/til/directory.rb', line 23

def notes
  note_list = NoteList.new
  note_paths.each do |note_path|
    note_list.push Note.new(note_path)
  end
  note_list
end