module NthDay
Constants
- VERSION
Public Class Methods
next_occurrence(day, now=Date.today)
click to toggle source
# File lib/nth_day.rb, line 5 def self.next_occurrence(day, now=Date.today) n = day.split.first[/\d/].to_i w = self.wday_named(day.split.last) now.step(now + 37).select{|d| d.nth_wday?(n, w) }.first end
wday_named(name)
click to toggle source
# File lib/nth_day.rb, line 11 def self.wday_named(name) ["su", "mo", "tu", "we", "th", "fr", "sa"].index(name[0..1].downcase) end