Parent

Methods

Included Modules

Facter::Util::Confine

Attributes

fact[RW]
values[RW]

Public Class Methods

new(fact, *values) click to toggle source

Add the restriction. Requires the fact name, an operator, and the value we’re comparing to.

    # File lib/facter/util/confine.rb, line 13
13:   def initialize(fact, *values)
14:     raise ArgumentError, "The fact name must be provided" unless fact
15:     raise ArgumentError, "One or more values must be provided" if values.empty?
16:     @fact = fact
17:     @values = values
18:   end

Public Instance Methods

to_s() click to toggle source
    # File lib/facter/util/confine.rb, line 20
20:   def to_s
21:     return "'%s' '%s'" % [@fact, @values.join(",")]
22:   end
true?() click to toggle source

Evaluate the fact, returning true or false.

    # File lib/facter/util/confine.rb, line 25
25:   def true?
26:     unless fact = Facter[@fact]
27:       Facter.debug "No fact for %s" % @fact
28:       return false
29:     end
30:     value = convert(fact.value)
31: 
32:     return false if value.nil?
33: 
34:     @values.each do |v|
35:       v = convert(v)
36:       next unless v.class == value.class
37:       return true if value == v
38:     end
39:     return false
40:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.