Module: TimeBoss::Calendar::Support::Navigable
- Included in:
- Unit
- Defined in:
- lib/timeboss/calendar/support/navigable.rb
Instance Method Summary collapse
-
#ago(quantity) ⇒ Unit
Fetch the unit some number of units prior to this unit.
-
#ahead(quantity) ⇒ Unit
Fetch the unit some number of units after this unit.
- #next(quantity = nil) ⇒ Object
- #previous(quantity = nil) ⇒ Object
-
#until(end_date) ⇒ Array<Unit>
Fetch a list of units from this unit until some date.
Instance Method Details
#ago(quantity) ⇒ Unit
Fetch the unit some number of units prior to this unit.
34 35 36 |
# File 'lib/timeboss/calendar/support/navigable.rb', line 34 def ago(quantity) previous(quantity + 1).first end |
#ahead(quantity) ⇒ Unit
Fetch the unit some number of units after this unit.
41 42 43 |
# File 'lib/timeboss/calendar/support/navigable.rb', line 41 def ahead(quantity) self.next(quantity + 1).last end |
#next ⇒ Unit #next(value) ⇒ Array<Unit>
26 27 28 29 |
# File 'lib/timeboss/calendar/support/navigable.rb', line 26 def next(quantity = nil) return up if quantity.nil? gather(:next, quantity) end |
#previous ⇒ Unit #previous(value) ⇒ Array<Unit>
14 15 16 17 |
# File 'lib/timeboss/calendar/support/navigable.rb', line 14 def previous(quantity = nil) return down if quantity.nil? gather(:previous, quantity).reverse end |
#until(end_date) ⇒ Array<Unit>
Fetch a list of units from this unit until some date.
48 49 50 51 52 53 54 55 56 |
# File 'lib/timeboss/calendar/support/navigable.rb', line 48 def until(end_date) entry = self [entry].tap do |entries| until entry.end_date >= end_date entry = entry.next entries << entry end end end |