From 22d99300b473d637a8d123514aa822acf0fd84ca Mon Sep 17 00:00:00 2001 From: Jon Allured Date: Mon, 4 Nov 2024 21:22:29 -0600 Subject: [PATCH] Move chore list item logic into model --- app/models/daily_packet.rb | 23 +++++++++++++++++++++++ app/models/daily_packet/pdf_view.rb | 16 ++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/models/daily_packet.rb b/app/models/daily_packet.rb index 413807e..00e3fcb 100644 --- a/app/models/daily_packet.rb +++ b/app/models/daily_packet.rb @@ -31,4 +31,27 @@ def headline_phrase def reading_list_phrase "#{reading_list_pace} pages/day" end + + def chore_list + built_on_weekend = built_on.saturday? || built_on.sunday? + built_on_summertime = (4..10).cover?(built_on.month) + + chores = [] + chores << "unload dishwasher" + chores << "collect laundry" if built_on_weekend + chores << "defrost meat" + + if built_on_weekend && built_on_summertime + chores << "poop patrol" + chores << "mow front" + chores << "mow back" + chores << "mow way back" + end + + chores << "put out garbage cans" if built_on.monday? + chores << "wipe off kitchen table" + chores << "run dishwasher" + + chores + end end diff --git a/app/models/daily_packet/pdf_view.rb b/app/models/daily_packet/pdf_view.rb index 55f13c7..58916c1 100644 --- a/app/models/daily_packet/pdf_view.rb +++ b/app/models/daily_packet/pdf_view.rb @@ -100,22 +100,10 @@ def draw_chore_list_page move_down 30 - built_on_weekend = daily_packet.built_on.saturday? || daily_packet.built_on.sunday? - built_on_summertime = (4..10).cover?(daily_packet.built_on.month) - font_size(20) do - text "unload dishwasher" - text "collect laundry" if daily_packet.built_on.saturday? || daily_packet.built_on.sunday? - text "defrost meat" - if built_on_weekend && built_on_summertime - text "poop patrol" - text "mow front" - text "mow back" - text "mow way back" + daily_packet.chore_list.each do |chore| + text chore end - text "put out garbage cans" if daily_packet.built_on.monday? - text "wipe off kitchen table" - text "run dishwasher" end end end