Holiday Wishes

Some people object to the phrase “Happy Holidays,” so I did this instead. wishes = []

If someone celebrates no holidays, we need to

make sure we have a blank array and not nil

reader.holidays_celebrated ||= []

We can't lump these together because some people celebrate more than one holiday.

if reader.holidays_celebrated.include?(Christmas) wishes << "Merry Christmas" end

It's transliterated a few different ways so try to include several

if reader.holidays_celebrated.include?(Hanukkah) || reader.holidays_celebrated.include?(חנוכה) || reader.holidays_celebrated.include?(Chanukah)

I think they're already a few weeks in, but whatever

wishes << "Happy Hanukkah" end

if reader.holidays_celebrated.include?(Kwanzaa) wishes << "Happy Kwanzaa" end

if reader.holidays_celebrated.include?(Festivus) wishes << "Happy Festivus (for the rest of us)" end

This goes for everyone, but we want it at the end so the formatting is right

wishes << "Happy New Year"

The holiday greetings:

<%= wishes.join(' and ') %>

That’s really not ideal. I think I’d probably prefer to iterate over a hashmap with holidays and the greetings, so that the code would be much cleaner.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.