module RST::Calendar::Eventable
Inject Eventable
to any Class to make it event-able in a Calendar
You have to define a method :event_headline for the class in order to list the event in a Calendar
.
@example
class Birthday < Struct.new(:name,:dob) include Eventable def initialize(*args) super schedule!(dob) end protected def event_headline "It's #{name}'s Birthday" end end
Public Instance Methods
event_date()
click to toggle source
@return [Date] the date when the event is scheduled
# File lib/modules/calendar/eventable.rb, line 27 def event_date @event_date end
event_headline()
click to toggle source
used in calendar-output as a short entry @abstract - overwrite in descendants @return [String]
# File lib/modules/calendar/eventable.rb, line 46 def event_headline self.inspect end
schedule!(date)
click to toggle source
@param [Date|String] date schedule this object for the given date @return [Eventable] - self
# File lib/modules/calendar/eventable.rb, line 38 def schedule!(date) @event_date = date.is_a?(Date) ? date : Date.parse(date) self end
scheduled?()
click to toggle source
@return [Boolean] true if the object is scheduled (has an event_date
)
# File lib/modules/calendar/eventable.rb, line 32 def scheduled? !event_date.nil? end