Class: Clavius::Schedule
- Inherits:
-
Object
- Object
- Clavius::Schedule
- Extended by:
- Forwardable
- Defined in:
- lib/clavius/schedule.rb
Instance Method Summary collapse
- #active?(date) ⇒ Boolean
- #after(date) ⇒ Object
- #before(date) ⇒ Object
- #between(start_date, end_date) ⇒ Object
- #days(number) ⇒ Object
-
#initialize(&config) ⇒ Schedule
constructor
A new instance of Schedule.
Constructor Details
#initialize(&config) ⇒ Schedule
Returns a new instance of Schedule.
6 7 8 |
# File 'lib/clavius/schedule.rb', line 6 def initialize(&config) @configuration = Configuration.new(&config) end |
Instance Method Details
#active?(date) ⇒ Boolean
26 27 28 29 30 31 |
# File 'lib/clavius/schedule.rb', line 26 def active?(date) date = date.to_date (weekdays.include?(date.wday) || included.include?(date)) && !excluded.include?(date) end |
#after(date) ⇒ Object
21 22 23 24 |
# File 'lib/clavius/schedule.rb', line 21 def after(date) date.to_date.next_day.upto(Time::HEAT_DEATH).lazy .select(&method(:active?)) end |
#before(date) ⇒ Object
16 17 18 19 |
# File 'lib/clavius/schedule.rb', line 16 def before(date) date.to_date.prev_day.downto(Time::BIG_BANG).lazy .select(&method(:active?)) end |
#between(start_date, end_date) ⇒ Object
37 38 39 40 |
# File 'lib/clavius/schedule.rb', line 37 def between(start_date, end_date) start_date.to_date.upto(end_date.to_date.prev_day) .select(&method(:active?)) end |
#days(number) ⇒ Object
33 34 35 |
# File 'lib/clavius/schedule.rb', line 33 def days(number) Calculation::DaysFrom.new(self, number) end |