Class: FaHarnessTools::Schedule
- Inherits:
-
Object
- Object
- FaHarnessTools::Schedule
- Defined in:
- lib/fa-harness-tools/schedule.rb
Overview
Creates a schedule which can be used to check if a change should be deployed.
Instance Method Summary collapse
- #can_run?(time:) ⇒ Boolean
-
#initialize(schedule:) ⇒ Schedule
constructor
A new instance of Schedule.
- #to_s ⇒ Object
Constructor Details
#initialize(schedule:) ⇒ Schedule
Returns a new instance of Schedule.
7 8 9 10 11 |
# File 'lib/fa-harness-tools/schedule.rb', line 7 def initialize(schedule:) @schedule = schedule @cron_schedule = Fugit.parse(schedule) raise InvalidScheduleError, "'#{schedule}' can not be parsed" unless @cron_schedule end |
Instance Method Details
#can_run?(time:) ⇒ Boolean
13 14 15 16 |
# File 'lib/fa-harness-tools/schedule.rb', line 13 def can_run?(time:) return false unless @cron_schedule.day_match?(time) return @cron_schedule.hour_match?(time) end |
#to_s ⇒ Object
18 19 20 |
# File 'lib/fa-harness-tools/schedule.rb', line 18 def to_s return @schedule end |