class Chef::Resource::Cron
Public Class Methods
new(name, run_context = nil)
click to toggle source
Calls superclass method
Chef::Resource::new
# File lib/chef/resource/cron.rb, line 36 def initialize(name, run_context = nil) super @minute = "*" @hour = "*" @day = "*" @month = "*" @weekday = "*" end
Public Instance Methods
day(arg = nil)
click to toggle source
# File lib/chef/resource/cron.rb, line 79 def day(arg = nil) if arg.is_a?(Integer) converted_arg = arg.to_s else converted_arg = arg end begin if integerize(arg) > 31 then raise RangeError end rescue ArgumentError end set_or_return( :day, converted_arg, kind_of: String ) end
hour(arg = nil)
click to toggle source
# File lib/chef/resource/cron.rb, line 62 def hour(arg = nil) if arg.is_a?(Integer) converted_arg = arg.to_s else converted_arg = arg end begin if integerize(arg) > 23 then raise RangeError end rescue ArgumentError end set_or_return( :hour, converted_arg, kind_of: String ) end
minute(arg = nil)
click to toggle source
# File lib/chef/resource/cron.rb, line 45 def minute(arg = nil) if arg.is_a?(Integer) converted_arg = arg.to_s else converted_arg = arg end begin if integerize(arg) > 59 then raise RangeError end rescue ArgumentError end set_or_return( :minute, converted_arg, kind_of: String ) end
month(arg = nil)
click to toggle source
# File lib/chef/resource/cron.rb, line 96 def month(arg = nil) if arg.is_a?(Integer) converted_arg = arg.to_s else converted_arg = arg end begin if integerize(arg) > 12 then raise RangeError end rescue ArgumentError end set_or_return( :month, converted_arg, kind_of: String ) end
weekday(arg = nil)
click to toggle source
# File lib/chef/resource/cron.rb, line 113 def weekday(arg = nil) if arg.is_a?(Integer) converted_arg = arg.to_s else converted_arg = arg end begin error_message = "You provided '#{arg}' as a weekday, acceptable values are " error_message << Provider::Cron::WEEKDAY_SYMBOLS.map { |sym| ":#{sym}" }.join(", ") error_message << " and a string in crontab format" if (arg.is_a?(Symbol) && !Provider::Cron::WEEKDAY_SYMBOLS.include?(arg)) || (!arg.is_a?(Symbol) && integerize(arg) > 7) || (!arg.is_a?(Symbol) && integerize(arg) < 0) raise RangeError, error_message end rescue ArgumentError end set_or_return( :weekday, converted_arg, kind_of: [String, Symbol] ) end
Private Instance Methods
integerize(integerish)
click to toggle source
# File lib/chef/resource/cron.rb, line 167 def integerize(integerish) Integer(integerish) rescue TypeError 0 end