module NextDate::Date
Public Class Methods
included(base)
click to toggle source
# File lib/next_date/date.rb, line 3 def self.included(base) base.class_eval do ::Date::DAYNAMES.each_with_index do |day, index| next_day = "next_#{day.downcase}" define_singleton_method next_day do |after: ::Date.today| if after.wday == index after += 7 else after += (7 - (after.wday - index)) % 7 end end define_method next_day do self.class.send(next_day, after: self) end end end end