Class: Medo::Notes
- Inherits:
-
Object
- Object
- Medo::Notes
- Extended by:
- Forwardable
- Includes:
- Comparable, Enumerable
- Defined in:
- lib/medo/notes.rb
Instance Method Summary collapse
- #<<(other) ⇒ Object
- #==(other) ⇒ Object
- #each ⇒ Object
-
#initialize(*args) ⇒ Notes
constructor
A new instance of Notes.
- #initialize_copy(source) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(*args) ⇒ Notes
Returns a new instance of Notes.
11 12 13 |
# File 'lib/medo/notes.rb', line 11 def initialize(*args) @notes = args.flatten.map { |n| n.to_s.strip }.reject(&:empty?).join("\n") end |
Instance Method Details
#<<(other) ⇒ Object
15 16 17 18 |
# File 'lib/medo/notes.rb', line 15 def <<(other) @notes << "\n#{other}" @notes.lstrip! end |
#==(other) ⇒ Object
24 25 26 27 |
# File 'lib/medo/notes.rb', line 24 def ==(other) return true if other.equal? self other.to_s == @notes end |
#each ⇒ Object
20 21 22 |
# File 'lib/medo/notes.rb', line 20 def each @notes.each_line { |line| yield line.chomp } end |
#initialize_copy(source) ⇒ Object
29 30 31 32 |
# File 'lib/medo/notes.rb', line 29 def initialize_copy(source) super @notes = @notes.dup end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/medo/notes.rb', line 34 def to_s @notes end |