Class: WB::Note
- Inherits:
-
Object
- Object
- WB::Note
- Defined in:
- lib/wb/note.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
- .all ⇒ Object
- .find_by_basename(basename) ⇒ Object
- .find_by_full_path(full_path) ⇒ Object
- .find_by_number(number) ⇒ Object
- .find_note(name) ⇒ Object
- .list_notes ⇒ Object
Instance Method Summary collapse
-
#initialize(path, number) ⇒ Note
constructor
A new instance of Note.
- #to_s ⇒ Object
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
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/wb/note.rb', line 5 def number @number end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/wb/note.rb', line 5 def path @path end |
Class Method Details
.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_notes ⇒ Object
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_s ⇒ Object
36 37 38 |
# File 'lib/wb/note.rb', line 36 def to_s %Q(#{number}: #{path}) end |