Class: WB::Note

Inherits:
Object
  • Object
show all
Defined in:
lib/wb/note.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, number) ⇒ Note

Returns a new instance of Note.



31
32
33
34
# File 'lib/wb/note.rb', line 31

def initialize(path, number)
  @path = path
  @number = number.to_s
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



5
6
7
# File 'lib/wb/note.rb', line 5

def number
  @number
end

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/wb/note.rb', line 5

def path
  @path
end

Class Method Details

.allObject



7
8
9
# File 'lib/wb/note.rb', line 7

def self.all
  WB.config.notes
end

.find_by_basename(basename) ⇒ Object



19
20
21
# File 'lib/wb/note.rb', line 19

def self.find_by_basename(basename)
  all.find { |note| File.basename(note.path) == basename }
end

.find_by_full_path(full_path) ⇒ Object



15
16
17
# File 'lib/wb/note.rb', line 15

def self.find_by_full_path(full_path)
  all.find { |note| note.path == full_path }
end

.find_by_number(number) ⇒ Object



11
12
13
# File 'lib/wb/note.rb', line 11

def self.find_by_number(number)
  all.find { |note| note.number == number }
end

.find_note(name) ⇒ Object



23
24
25
# File 'lib/wb/note.rb', line 23

def self.find_note(name)
  find_by_full_path(name) || find_by_basename(name)
end

.list_notesObject



27
28
29
# File 'lib/wb/note.rb', line 27

def self.list_notes
  all.each { |note| $stdout.puts note }
end

Instance Method Details

#to_sObject



36
37
38
# File 'lib/wb/note.rb', line 36

def to_s
  %Q(#{number}: #{path})
end