Add the restriction. Requires the fact name, an operator, and the value we’re comparing to.
# File lib/facter/util/confine.rb, line 13 def initialize(fact, *values) raise ArgumentError, "The fact name must be provided" unless fact raise ArgumentError, "One or more values must be provided" if values.empty? @fact = fact @values = values end
# File lib/facter/util/confine.rb, line 20 def to_s return "'%s' '%s'" % [@fact, @values.join(",")] end
Evaluate the fact, returning true or false.
# File lib/facter/util/confine.rb, line 25 def true? unless fact = Facter[@fact] Facter.debug "No fact for %s" % @fact return false end value = convert(fact.value) return false if value.nil? return @values.any? { |v| convert(v) === value } end
Generated with the Darkfish Rdoc Generator 2.