Class: Woli::Diary
- Inherits:
-
Object
- Object
- Woli::Diary
- Defined in:
- lib/woli/diary.rb
Instance Attribute Summary collapse
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
Instance Method Summary collapse
- #all_entries_dates ⇒ Object
- #entry(date) ⇒ Object
-
#initialize(repository) ⇒ Diary
constructor
A new instance of Diary.
- #load_or_create_entry(date) ⇒ Object
- #missing_entries_count ⇒ Object
Constructor Details
#initialize(repository) ⇒ Diary
Returns a new instance of Diary.
5 6 7 |
# File 'lib/woli/diary.rb', line 5 def initialize(repository) @repository = repository end |
Instance Attribute Details
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
3 4 5 |
# File 'lib/woli/diary.rb', line 3 def repository @repository end |
Instance Method Details
#all_entries_dates ⇒ Object
9 10 11 |
# File 'lib/woli/diary.rb', line 9 def all_entries_dates @repository.all_entries_dates end |
#entry(date) ⇒ Object
13 14 15 |
# File 'lib/woli/diary.rb', line 13 def entry(date) @repository.load_entry(date) end |
#load_or_create_entry(date) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/woli/diary.rb', line 17 def load_or_create_entry(date) entry = @repository.load_entry(date) return entry if entry DiaryEntry.new(date, '', @repository) end |
#missing_entries_count ⇒ Object
24 25 26 27 28 |
# File 'lib/woli/diary.rb', line 24 def missing_entries_count last_entry_date = @repository.all_entries_dates.last return 0 unless last_entry_date Integer(Date.today - last_entry_date) end |