class TickTack::Calendar

Attributes

conf[R]

Public Class Methods

new(now = nil, conf = {}) click to toggle source
# File lib/tick_tack/calendar.rb, line 6
def initialize(now = nil, conf = {})
  self.now = now
  @conf = {
    dow: 0 # day of week - 0 = sunday, 1 = monday
  }.merge!(conf)
end

Protected Class Methods

factory(class_id) click to toggle source
# File lib/tick_tack/calendar.rb, line 35
def self.factory class_id
  {
    :Year => Year,
    :Month => Month,
    :Day => Day
  }[class_id]
end

Public Instance Methods

day(*args) click to toggle source
# File lib/tick_tack/calendar.rb, line 29
def day(*args)
  self.class.factory(:Day).new(self, *args)
end
month(*args) click to toggle source
# File lib/tick_tack/calendar.rb, line 25
def month(*args)
  self.class.factory(:Month).new(self, *args)
end
now() click to toggle source
# File lib/tick_tack/calendar.rb, line 17
def now
  @now.nil? ? DateTime.now.to_date : @now
end
now=(now) click to toggle source
# File lib/tick_tack/calendar.rb, line 13
def now=(now)
  @now = now
end
year(*args) click to toggle source
# File lib/tick_tack/calendar.rb, line 21
def year(*args)
  self.class.factory(:Year).new(self, *args)
end