class TickTack::Year

Public Class Methods

new(calendar, year_i = nil) click to toggle source
# File lib/tick_tack/year.rb, line 6
def initialize(calendar, year_i = nil)
  @calendar = calendar
  init_year(year_i)

  @first_day_date = Date.new(self.year_i, 1, 1)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/tick_tack/year.rb, line 55
def <=>(other)
  self.first_day.date <=> other.first_day.date
end
contains?(other) click to toggle source
# File lib/tick_tack/year.rb, line 32
def contains?(other)
  range = (first_day.date.jd..last_day.date.jd)
  if other.is_a? Month
    range === other.first_day.date.jd
  elsif other.is_a? Day
    range === other.date.jd
  else
    false
  end
end
first_day() click to toggle source
# File lib/tick_tack/year.rb, line 13
def first_day
  @calendar.day(year_i, 1, 1)
end
last_day() click to toggle source
# File lib/tick_tack/year.rb, line 17
def last_day
  date = (@first_day_date >> 12) - 1
  @calendar.day(year_i, date.month, date.day)
end
month(month_i) click to toggle source
# File lib/tick_tack/year.rb, line 22
def month(month_i)
  @calendar.month(year_i, month_i)
end
months() click to toggle source
# File lib/tick_tack/year.rb, line 26
def months
  (1..12).map do |i|
    month(i)
  end
end
next() click to toggle source
# File lib/tick_tack/year.rb, line 43
def next
  next_date = @first_day_date.next_year
  @calendar.year(next_date.year)
end
Also aliased as: succ
prev()
Alias for: previous
previous() click to toggle source
# File lib/tick_tack/year.rb, line 49
def previous
  prev_date = @first_day_date.prev_year
  @calendar.year(prev_date.year)
end
Also aliased as: prev
succ()
Alias for: next