class Aebus::Config::BackupSchedule
Attributes
keep[R]
label[R]
last_deadline[R]
next_deadline[R]
Public Class Methods
new(current_time_utc, label, backup_config)
click to toggle source
# File lib/config/volume.rb, line 13 def initialize (current_time_utc, label, backup_config) @label = label if backup_config['enabled'] calculate_deadlines(current_time_utc, backup_config['when']) end @keep = backup_config['keep'] # we use Infinity to model the keep all @keep = 1.0 / 0 if (@keep.nil? || @keep.eql?(KEEP_ALL)) end
parse_backups_config(current_time_utc, backups_config)
click to toggle source
# File lib/config/volume.rb, line 37 def self.parse_backups_config(current_time_utc, backups_config) return nil unless backups_config result = Hash.new backups_config.each_pair do |key,value| result.store(key, BackupSchedule.new(current_time_utc, key, value)) end result end
Public Instance Methods
calculate_deadlines(current_time_utc, when_string)
click to toggle source
# File lib/config/volume.rb, line 24 def calculate_deadlines(current_time_utc, when_string) raise(ArgumentError, 'when field cannot be empty if the backup is enabled') unless when_string parser = CronParser.new (when_string) @last_deadline = parser.last(current_time_utc) @next_deadline = parser.next(current_time_utc) end
to_s()
click to toggle source
# File lib/config/volume.rb, line 33 def to_s "Backup Schedule: label => #{@label} last_deadline => #{@last_deadline} next_deadline => #{@next_deadline} keep => #{@keep}" end