Class: RRule::Rule
- Inherits:
-
Object
- Object
- RRule::Rule
- Defined in:
- lib/rrule/rule.rb
Instance Attribute Summary collapse
-
#dtstart ⇒ Object
readonly
Returns the value of attribute dtstart.
-
#exdate ⇒ Object
readonly
Returns the value of attribute exdate.
-
#rrule ⇒ Object
readonly
Returns the value of attribute rrule.
-
#tz ⇒ Object
readonly
Returns the value of attribute tz.
Instance Method Summary collapse
- #all ⇒ Object
- #between(start_date, end_date) ⇒ Object
-
#initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: []) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: []) ⇒ Rule
Returns a new instance of Rule.
5 6 7 8 9 10 11 12 13 |
# File 'lib/rrule/rule.rb', line 5 def initialize(rrule, dtstart: Time.now, tzid: 'UTC', exdate: []) @rrule = rrule # This removes all sub-second and floors it to the second level. # Sub-second level calculations breaks a lot of assumptions in this # library and rounding it may also cause unexpected inequalities. @dtstart = Time.at(dtstart.to_i).in_time_zone(tzid) @tz = tzid @exdate = exdate end |
Instance Attribute Details
#dtstart ⇒ Object (readonly)
Returns the value of attribute dtstart.
3 4 5 |
# File 'lib/rrule/rule.rb', line 3 def dtstart @dtstart end |
#exdate ⇒ Object (readonly)
Returns the value of attribute exdate.
3 4 5 |
# File 'lib/rrule/rule.rb', line 3 def exdate @exdate end |
#rrule ⇒ Object (readonly)
Returns the value of attribute rrule.
3 4 5 |
# File 'lib/rrule/rule.rb', line 3 def rrule @rrule end |
#tz ⇒ Object (readonly)
Returns the value of attribute tz.
3 4 5 |
# File 'lib/rrule/rule.rb', line 3 def tz @tz end |
Instance Method Details
#all ⇒ Object
15 16 17 |
# File 'lib/rrule/rule.rb', line 15 def all reject_exdates(all_until(nil)) end |
#between(start_date, end_date) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rrule/rule.rb', line 19 def between(start_date, end_date) # This removes all sub-second and floors it to the second level. # Sub-second level calculations breaks a lot of assumptions in this # library and rounding it may also cause unexpected inequalities. floored_start_date = Time.at(start_date.to_i) floored_end_date = Time.at(end_date.to_i) reject_exdates(all_until(floored_end_date).reject { |instance| instance < floored_start_date }) end |