Class: RecurrenceTime
- Inherits:
-
Object
- Object
- RecurrenceTime
- Includes:
- Enumerable
- Defined in:
- lib/recurrence_time.rb
Instance Method Summary collapse
-
#advance_to(new_start_time) ⇒ Object
Skips all dates in the series before the given date.
- #each ⇒ Object
- #has_next? ⇒ Boolean
-
#initialize(rdata, start_time = JTime.new, strict = true) ⇒ RecurrenceTime
constructor
Initializes a RecurrenceTime objects which generates JTime based on recurrence rule.
-
#next ⇒ Object
Returns a JTime for the instance of next recurrence time.
- #to_java ⇒ Object
Constructor Details
#initialize(rdata, start_time = JTime.new, strict = true) ⇒ RecurrenceTime
Initializes a RecurrenceTime objects which generates JTime based on recurrence rule
Options
rdata-
it can be one of the following:
-
RRULE, EXRULE, RDATE, and EXDATE lines (RFC 2445 content strings)
-
RRule or RDateList object
-
Array of RRule and RDateList objects, which can be a combinations of RRULE and EXRULE
-
start_time-
Optional. Start time of the recurrence time. The default is now
strict-
Optional. Any failure to parse should result in a ParseException false causes bad content lines to be logged and ignored. Default is true
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/recurrence_time.rb', line 21 def initialize(rdata, start_time=JTime.new, strict=true) rdata = rdata.to_ical if (rdata.kind_of? RRule or rdata.kind_of? RDateList) rdata = (rdata.map {|r| r.to_ical}).join("\n") if rdata.kind_of? Array @iterator = DateTimeIteratorFactory.createDateTimeIterator(rdata, start_time.to_java, start_time.java_zone, strict) self end |
Instance Method Details
#advance_to(new_start_time) ⇒ Object
Skips all dates in the series before the given date.
Options
new_start_time-
JTime which the iterator is advanced to.
42 43 44 45 |
# File 'lib/recurrence_time.rb', line 42 def advance_to(new_start_time) @iterator.advanceTo(new_start_time.to_java) self end |
#each ⇒ Object
55 56 57 |
# File 'lib/recurrence_time.rb', line 55 def each yield self.next until self.has_next? == false end |
#has_next? ⇒ Boolean
47 48 49 |
# File 'lib/recurrence_time.rb', line 47 def has_next? @iterator.hasNext end |
#next ⇒ Object
Returns a JTime for the instance of next recurrence time
33 34 35 |
# File 'lib/recurrence_time.rb', line 33 def next @iterator.hasNext ? JTime.new(@iterator.next) : nil end |
#to_java ⇒ Object
51 52 53 |
# File 'lib/recurrence_time.rb', line 51 def to_java @iterator end |