Class: WorkLogController

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

Instance Method Summary collapse

Instance Method Details

#add_work_log(date, description) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/work_log_controller.rb', line 9

def add_work_log(date, description)
  if description.nil? || description.empty?
    raise ArgumentError, 'Description must not be empty'
  end

  WorkLogFileDao.new.save(create_work_log(date, description))
end

#delete(id) ⇒ Object



25
26
27
# File 'lib/work_log_controller.rb', line 25

def delete(id)
  WorkLogFileDao.new.delete(id)
end

#find_by_month_and_year(month, year) ⇒ Object



29
30
31
# File 'lib/work_log_controller.rb', line 29

def find_by_month_and_year(month, year)
  sort_by_date(WorkLogFileDao.new.find_by_month_and_year(month, year))
end

#find_by_year(year) ⇒ Object



33
34
35
# File 'lib/work_log_controller.rb', line 33

def find_by_year(year)
  sort_by_date(WorkLogFileDao.new.find_by_year(year))
end

#list(date) ⇒ Object



17
18
19
# File 'lib/work_log_controller.rb', line 17

def list(date)
  sort_by_date(WorkLogFileDao.new.list(parse_date(date)))
end

#list_allObject



21
22
23
# File 'lib/work_log_controller.rb', line 21

def list_all
  sort_by_date(WorkLogFileDao.new.list_all)
end