class TickTack::Month
Public Class Methods
new(calendar, year_i = nil, month_i = nil)
click to toggle source
# File lib/tick_tack/month.rb, line 6 def initialize(calendar, year_i = nil, month_i = nil) @calendar = calendar init_year(year_i) init_month(month_i) @first_day_date = Date.new(self.year_i, self.month_i, 1) end
Public Instance Methods
<=>(other)
click to toggle source
# File lib/tick_tack/month.rb, line 62 def <=>(other) self.first_day.date <=> other.first_day.date end
contains?(other)
click to toggle source
# File lib/tick_tack/month.rb, line 41 def contains?(other) range = (first_day.date.jd..last_day.date.jd) if other.is_a? Day range === other.date.jd else false end end
day(day_i)
click to toggle source
# File lib/tick_tack/month.rb, line 24 def day(day_i) @calendar.day(year_i, month_i, day_i) end
first_day()
click to toggle source
# File lib/tick_tack/month.rb, line 15 def first_day @calendar.day(year_i, month_i, 1) end
last_day()
click to toggle source
# File lib/tick_tack/month.rb, line 19 def last_day date = (@first_day_date >> 1) - 1 @calendar.day(year_i, month_i, date.day) end
next()
click to toggle source
# File lib/tick_tack/month.rb, line 50 def next next_date = @first_day_date.next_month @calendar.month(next_date.year, next_date.month) end
Also aliased as: succ
previous()
click to toggle source
# File lib/tick_tack/month.rb, line 56 def previous prev_date = @first_day_date.prev_month @calendar.month(prev_date.year, prev_date.month) end
Also aliased as: prev
weekdays()
click to toggle source
# File lib/tick_tack/month.rb, line 28 def weekdays first = first_day.week_start last = last_day.week_end weeks = [] while first < last weeks << first.weekdays first = first.week_end.next end weeks end