module Icalendar class Calendar < Component attr_accessor :events, :todos, :journals, :freebusys, :timezones def initialize() super("VCALENDAR") @properties = {} @property_params = {} @events = [] @todos = [] @journals = [] @freebusys = [] @timezones = [] end def add(component) if component.is_a? Event @events << component elsif component.is_a? Todo @todos << component elsif component.is_a? Journal @journals << component elsif component.is_a? Freebusy @freebusys << component elsif component.is_a? Timezone @timezones << component else raise InvalidComponentClass end end def to_s print_string do |s| @events.each { |event| s << event.to_s } @todos.each { |todo| s << todo.to_s } @journals.each { |journal| s << journal.to_s } @freebusys.each { |freebusy| s << freebusy.to_s } @timezones.each { |timezone| s << timezone.to_s } end end end end