Class Facter::Tag
In: lib/facter.rb
Parent: Object

A restricting tag for fact resolution mechanisms. The tag must be true for the resolution mechanism to be suitable.

Methods

new   to_s   true?  

Attributes

fact  [RW] 
op  [RW] 
value  [RW] 

Public Class methods

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

[Source]

     # File lib/facter.rb, line 480
480:         def initialize(fact, *values)
481:             @fact = fact
482:             @values = values
483:         end

Public Instance methods

[Source]

     # File lib/facter.rb, line 485
485:         def to_s
486:             return "'%s' '%s'" % [@fact, @values.join(",")]
487:         end

Evaluate the fact, returning true or false.

[Source]

     # File lib/facter.rb, line 490
490:         def true?
491:             fact = nil
492:             unless fact = Facter[@fact]
493:                 Facter.debug "No fact for %s" % @fact
494:                 return false
495:             end
496:             value = fact.value
497: 
498:             if value.nil?
499:                 return false
500:             end
501: 
502:             retval = @values.find { |v|
503:                 if value == v
504:                     break true
505:                 end
506:             }
507: 
508:             if retval
509:                 retval = true
510:             else
511:                 retval = false
512:             end
513: 
514:             return retval || false
515:         end

[Validate]