我将事件添加到 iCalendar:
require 'icalendar'
calendar = Icalendar::Calendar.new
...some properties to calendar
event = Icalendar::Event.new
...some properties to event 1
calendar.add_event(event)
event = Icalendar::Event.new
...some properties to event 2
calendar.add_event(event)
当我调用输出时,整个日历被发布(简化)
calendar.to_ical
BEGIN:VCALENDAR
BEGIN:VEVENT
...event 1
END:VEVENT
BEGIN:VEVENT
...event 2
END:VEVENT
END:VCALENDAR
如果我只调用事件 1 的输出
event.to_ical
BEGIN:VEVENT
...event 1
END:VEVENT
我只想输出这个事件的 VCalendar(就像一个过滤器)
BEGIN:VCALENDAR
BEGIN:VEVENT
...event 1
END:VEVENT
END:VCALENDAR
日历对象有办法吗?
最佳答案
require 'icalendar'
calendar = Icalendar::Calendar.new
...some properties to calendar
event = Icalendar::Event.new
...some properties to event 1
calendar.add_event(event)
calendar_as_string = "BEGIN:VCALENDAR\n#{event.to_ical}\nEND:VCALENDAR"
有点hack,但它应该对你进行排序...... calendar.to_ical 打印什么?根据tests ,看起来它会做你需要的。
关于ruby - 是否可以使用 ruby-iCalendar 导出只有一个事件的 VCalendar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32434657/