# class CronParam

A base class for all of the Cron parameters, since they all have similar argument checking going on.

### Attributes

boundaries[RW]
default[RW]

### Public Instance Methods

alphacheck(value, ary) click to toggle source

Verify that a value falls within the specified array. Does case insensitive matching, and supports matching either the entire word or the first three letters of the word.

    # File lib/puppet/type/cron.rb, line 83
    def alphacheck(value, ary)
      tmp = value.downcase

      # If they specified a shortened version of the name, then see
      # if we can lengthen it (e.g., mon => monday).
      if tmp.length == 3
        ary.each_with_index { |name, index|
          if tmp.upcase == name[0..2].upcase
            return index
          end
        }
      else
        return ary.index(tmp) if ary.include?(tmp)
      end

      false
    end

insync?(is) click to toggle source

We have to override the parent method, because we consume the entire “should” array

    # File lib/puppet/type/cron.rb, line 57
    def insync?(is)
      self.is_to_s(is) == self.should_to_s
    end

is_to_s(currentvalue = @is) click to toggle source

    # File lib/puppet/type/cron.rb, line 114
    def is_to_s(currentvalue = @is)
      if currentvalue
        return currentvalue unless currentvalue.is_a?(Array)

        if self.name == :command or currentvalue[0].is_a? Symbol
          currentvalue[0]
        else
          currentvalue.join(",")
        end
      else
        nil
      end
    end

limitcheck(num, lower, upper) click to toggle source

Verify that a number is within the specified limits. Return the number if it is, or false if it is not.

    # File lib/puppet/type/cron.rb, line 76
    def limitcheck(num, lower, upper)
      (num >= lower and num <= upper) && num
    end

numfix(num) click to toggle source

A method used to do parameter input handling. Converts integers in string form to actual integers, and returns the value if it’s an integer or false if it’s just a normal string.

    # File lib/puppet/type/cron.rb, line 64
    def numfix(num)
      if num =~ /^\d+$/
        return num.to_i
      elsif num.is_a?(Integer)
        return num
      else
        return false
      end
    end

should() click to toggle source

    # File lib/puppet/type/cron.rb, line 128
    def should
      if @should and @should[0] == :absent
        :absent
      else
        @should
      end
    end

should=(ary) click to toggle source
Calls superclass method Puppet::Property#should=

    # File lib/puppet/type/cron.rb, line 136
    def should=(ary)
      super
      @should.flatten!
    end

should_to_s(newvalue = @should) click to toggle source

    # File lib/puppet/type/cron.rb, line 101
    def should_to_s(newvalue = @should)
      if newvalue
        newvalue = [newvalue] unless newvalue.is_a?(Array)
        if self.name == :command or newvalue[0].is_a? Symbol
          newvalue[0]
        else
          newvalue.join(",")
        end
      else
        nil
      end
    end