如何使用ri_cal创建带标题的.ics事件

时间:2013-03-06 05:09:38

标签: ruby icalendar

我正在使用ri_cal gem来创建ics文件。宝石的文档建议我这样做:

RiCal.Calendar do |cal|
  cal.event do |event|
    event.description = "MA-6 First US Manned Spaceflight"
    event.dtstart =  DateTime.parse("2/20/1962 14:47:39")
    event.dtend = DateTime.parse("2/20/1962 19:43:02")
    event.location = "Cape Canaveral"
    event.add_attendee "john.glenn@nasa.gov"
    event.alarm do
      description "Segment 51"
    end
  end
end

但是当我打开在OS X日历中创建的.ics文件时,该事件没有标题。仅按描述设置了描述。

如何设置活动的标题?

1 个答案:

答案 0 :(得分:3)

使用event.summary

RiCal.Calendar do |cal|
  cal.event do |event|
    event.summary = "The 'title' of the event"
    event.description = "MA-6 First US Manned Spaceflight"
    event.dtstart =  DateTime.parse("2/20/1962 14:47:39")
    event.dtend = DateTime.parse("2/20/1962 19:43:02")
    event.location = "Cape Canaveral"
    event.add_attendee "john.glenn@nasa.gov"
    event.alarm do
      description "Segment 51"
    end
  end
end

ri_cal/properties/event.rb包含您可以设置的完整属性列表。