Class: FaHarnessTools::Schedule

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (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_sObject



18
19
20
# File 'lib/fa-harness-tools/schedule.rb', line 18

def to_s
  return @schedule
end