Class: Elected::Scheduler::Schedule
- Inherits:
-
Object
- Object
- Elected::Scheduler::Schedule
- Includes:
- Logging
- Defined in:
- lib/elected/scheduler/schedule.rb
Constant Summary collapse
- FIELDS =
{ seconds: :sec, minutes: :min, hours: :hour, days: :day, months: :month, dows: :wday }.freeze
- ABBR_DAYNAMES =
%w{ sun mon tue wed thu fri sat }.freeze
- DAYNAMES =
%w{ sunday monday tuesday wednesday thursday friday saturday }.freeze
- MONTHNAMES =
%w{ '' january february march april may june july august september october november december }.freeze
- ABBR_MONTHNAMES =
%w{ '' jan feb mar apr may jun jul aug sep oct nov dec }.freeze
- MIN_NUMBERS =
{ seconds: 0, minutes: 0, hours: 0, days: 1, months: 1, dows: 0 }.freeze
- MAX_NUMBERS =
{ seconds: 59, minutes: 59, hours: 23, days: 31, months: 12, dows: 6 }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Schedule
constructor
A new instance of Schedule.
- #matches?(time) ⇒ Boolean
- #to_cron_s ⇒ Object (also: #to_s, #inspect)
Constructor Details
Class Method Details
.defaults ⇒ Object
18 19 20 |
# File 'lib/elected/scheduler/schedule.rb', line 18 def self.defaults @defaults ||= { seconds: [0] } end |
Instance Method Details
#matches?(time) ⇒ Boolean
27 28 29 |
# File 'lib/elected/scheduler/schedule.rb', line 27 def matches?(time) FIELDS.all? { |field, meth| match? field, time.send(meth) } end |
#to_cron_s ⇒ Object Also known as: to_s, inspect
31 32 33 |
# File 'lib/elected/scheduler/schedule.rb', line 31 def to_cron_s FIELDS.keys.map { |field| get_cron_s(field) }.join(' ') end |