Class: RDateList
- Inherits:
-
Object
- Object
- RDateList
- Defined in:
- lib/rdate_list.rb
Constant Summary collapse
- RDATE =
'RDATE'
- EXDATE =
'EXDATE'
- VEVENT =
'VEVENT'
Instance Method Summary collapse
-
#ext_params ⇒ Object
Returns a hash map of any extension parameters such as the X-FOO=BAR in RRULE;X-FOO=BAR.
-
#initialize(timezone = nil, ical_string = nil) ⇒ RDateList
constructor
Initializes a RDateList with optionally a time zone ID and an iCal string.
-
#name ⇒ Object
Returns the type of the object name such as RRULE, EXRULE, or VEVENT.
-
#name=(new_name) ⇒ Object
Sets the type of the object such as RRULE, EXRULE, or VEVENT.
-
#to_ical ⇒ Object
Returns the unfolded RFC 2445 content line.
-
#to_java ⇒ Object
Returns the underlying Java object.
-
#utc_dates ⇒ Object
Returns the JTime in UTC time zone.
-
#utc_dates=(dates) ⇒ Object
Sets the dates.
-
#zone ⇒ Object
Returns the timezone ID.
-
#zone=(timezone) ⇒ Object
Sets the timezone using Time zone ID.
Constructor Details
#initialize(timezone = nil, ical_string = nil) ⇒ RDateList
Initializes a RDateList with optionally a time zone ID and an iCal string
Options
timezone
-
Optional. Time zone ID. For instance, the time zone ID for the U.S. Pacific Time zone is “America/Los_Angeles” If no timezone is specify, it uses time zone where the program is run
ical_string
-
Optional. The iCal string for the recurrent rule. The string must specify the rule type (RRULE, EXRULE or VEVENT)
22 23 24 25 26 27 28 |
# File 'lib/rdate_list.rb', line 22 def initialize(timezone=nil, ical_string=nil) tz = timezone ? JTimeZone.getTimeZone(timezone) : JTimeZone.getDefault @rdatelist = ical_string ? JRDateList.new(ical_string, tz) : JRDateList.new(tz) self end |
Instance Method Details
#ext_params ⇒ Object
Returns a hash map of any extension parameters such as the X-FOO=BAR in RRULE;X-FOO=BAR
42 43 44 45 46 47 48 |
# File 'lib/rdate_list.rb', line 42 def ext_params h = {} @rdatelist.getExtParams.to_a.each do |p| h[p[0]] = p[1] end h end |
#name ⇒ Object
Returns the type of the object name such as RRULE, EXRULE, or VEVENT
52 53 54 |
# File 'lib/rdate_list.rb', line 52 def name @rdatelist.getName end |
#name=(new_name) ⇒ Object
Sets the type of the object such as RRULE, EXRULE, or VEVENT
Options
new_name
-
‘RRULE’, ‘EXRULE’, or ‘VEVENT’
61 62 63 64 |
# File 'lib/rdate_list.rb', line 61 def name=(new_name) @rdatelist.setName(new_name) self end |
#to_ical ⇒ Object
Returns the unfolded RFC 2445 content line.
36 37 38 |
# File 'lib/rdate_list.rb', line 36 def to_ical @rdatelist.toIcal end |
#to_java ⇒ Object
Returns the underlying Java object
31 32 33 |
# File 'lib/rdate_list.rb', line 31 def to_java @rdatelist end |
#utc_dates ⇒ Object
Returns the JTime in UTC time zone
79 80 81 82 83 84 |
# File 'lib/rdate_list.rb', line 79 def utc_dates dates = @rdatelist.getDatesUtc dates.map do |d| JTime.utc(d.year, d.month, d.day) end end |
#utc_dates=(dates) ⇒ Object
Sets the dates. It will convert the dates into UTC.
87 88 89 90 91 92 93 94 |
# File 'lib/rdate_list.rb', line 87 def utc_dates=(dates) dates = dates.map do |d| utc_d = d.utc com.google.ical.values.DateValueImpl.new(utc_d.year, utc_d.month, utc_d.day) end @rdatelist.setDatesUtc(dates.to_java('com.google.ical.values.DateValue')) self end |
#zone ⇒ Object
Returns the timezone ID. For instance, the time zone ID for the U.S. Pacific Time zone is “America/Los_Angeles”
68 69 70 |
# File 'lib/rdate_list.rb', line 68 def zone @rdatelist.getTzid.getID end |
#zone=(timezone) ⇒ Object
Sets the timezone using Time zone ID
73 74 75 76 |
# File 'lib/rdate_list.rb', line 73 def zone=(timezone) @rdatelist.setTzid(JTimeZone.getTimeZone(timezone)) self end |