I'm trying to get the current day name in an object which I can then use to perform a basic calculation. Going around in circles currently.
I've got some attributes like this:
@location.monday_on
@location.monday_off
@location.tuesday_on
.....
I'm using these to figure out whether Time.now is within the range:
(@location.monday_on.to_i..@location.monday_off.to_i).include? Time.now.hour
That works fine. However, I wanted to dry things up and tried this:
start = "@location.#{Time.now.strftime('%A').downcase}_on".constantize
finish = "@location.#{Time.now.strftime('%A').downcase}_off".constantize
(start.to_i..finish.to_i).include? Time.now.hour
But, that gives an error about the wrong constant name. Was clutching at straws.
What's the best way to get the name of the current day in the object so I can use in a lookup?