Class: RST::Calendar::CalendarEvent

Inherits:
Object
  • Object
show all
Includes:
Eventable, RST::CalendarHelper
Defined in:
lib/modules/calendar/calendar_event.rb

Overview

A CalendarEvent happens on a given date and has a label. It can be used in a Calendar

Examples:


calendar = Calendar::Calendar.new('my calendar')
event = Calendar::CalendarEvent.new( 'today', "I'm happy" )
calendar << event
calendar.format_events_for(Date.today) 
  => "Sun, Mar 17 2013: I'm happy"
calendar << Calendar::CalendarEvent.new('2013-03-18', "Back to work :(")
calendar.list_days('today','4/2013')
  => Sun, Mar 17 2013: I'm happy
  => Mon, Mar 18 2013: Back to work :(

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RST::CalendarHelper

#parse_date_param

Methods included from Eventable

#schedule!, #scheduled?

Constructor Details

#initialize(_date, _label) ⇒ CalendarEvent

Returns a new instance of CalendarEvent.

Parameters:

  • _date (String|Date)
    • Date of the event (only all-day-events are possible yet)

  • _label (String)
    • Events name



30
31
32
33
34
# File 'lib/modules/calendar/calendar_event.rb', line 30

def initialize(_date,_label)
  @label = _label
  @id ||= SecureRandom::hex(4)
  schedule! parse_date_param(_date)
end

Instance Attribute Details

#event_dateObject (readonly)

Returns the value of attribute event_date.



23
24
25
# File 'lib/modules/calendar/calendar_event.rb', line 23

def event_date
  @event_date
end

#idObject (readonly)

Returns the value of attribute id.



23
24
25
# File 'lib/modules/calendar/calendar_event.rb', line 23

def id
  @id
end

#labelObject (readonly)

Returns the value of attribute label.



23
24
25
# File 'lib/modules/calendar/calendar_event.rb', line 23

def label
  @label
end

Instance Method Details

#event_headlineObject

override abstract method for an Eventable



37
38
39
# File 'lib/modules/calendar/calendar_event.rb', line 37

def event_headline
  self.label.to_s.strip
end