Class: Woli::DiaryEntry
- Inherits:
-
Object
- Object
- Woli::DiaryEntry
- Defined in:
- lib/woli/diary_entry.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(date, text, repository) ⇒ DiaryEntry
constructor
A new instance of DiaryEntry.
- #persist ⇒ Object
Constructor Details
#initialize(date, text, repository) ⇒ DiaryEntry
Returns a new instance of DiaryEntry.
6 7 8 9 10 |
# File 'lib/woli/diary_entry.rb', line 6 def initialize(date, text, repository) @date = date @text = text @repository = repository end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
3 4 5 |
# File 'lib/woli/diary_entry.rb', line 3 def date @date end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
3 4 5 |
# File 'lib/woli/diary_entry.rb', line 3 def repository @repository end |
#text ⇒ Object
Returns the value of attribute text.
4 5 6 |
# File 'lib/woli/diary_entry.rb', line 4 def text @text end |
Instance Method Details
#persist ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/woli/diary_entry.rb', line 12 def persist if text.strip.length > 0 repository.save_entry(self) else puts "Empty entry -- removing." repository.delete_entry(self) end end |