lib/what_date/client.rb in what_date-0.1.0 vs lib/what_date/client.rb in what_date-0.1.1

- old
+ new

@@ -1,13 +1,29 @@ require 'active_support' require 'active_support/core_ext/date/calculations' +require 'what_date/date_of_month' + module WhatDate class Client + include WhatDate::DateOfMonth Date::DAYS_INTO_WEEK.each do |day, inc| define_method(day) do |ref_date=nil| ref_date ||= Date.today ref_date.monday.days_since(inc) end end + + Date::DAYS_INTO_WEEK.each do |day, inc| + define_method("prev_#{day.to_s}".to_sym) do |ref_date = nil| + send(day, ref_date).days_ago(7) + end + end + + Date::DAYS_INTO_WEEK.each do |day, inc| + define_method("next_#{day.to_s}".to_sym) do |ref_date = nil| + send(day, ref_date).days_since(7) + end + end + end end