Class: Woli::Diary

Inherits:
Object
  • Object
show all
Defined in:
lib/woli/diary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#repositoryObject (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_datesObject



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_countObject



24
25
26
27
28
# File 'lib/woli/diary.rb', line 24

def missing_entries_count
   = @repository.all_entries_dates.last
  return 0 unless 
  Integer(Date.today - )
end