Class: Puppet::Parameter::Value Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/parameter/value.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Note:

this class should be used via the api methods in Puppet::Parameter and Puppet::Property

Describes an acceptable value for a parameter or property. An acceptable value is either specified as a literal value or a regular expression.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Value

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the instance with a literal accepted value, or a regular expression. If anything else is passed, it is turned into a String, and then made into a Symbol.

Parameters:

  • name (Symbol, Regexp, Object)

    the value to accept, Symbol, a regular expression, or object to convert.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/puppet/parameter/value.rb', line 40

def initialize(name)
  if name.is_a?(Regexp)
    @name = name
  else
    # Convert to a string and then a symbol, so things like true/false
    # still show up as symbols.
    @name = convert(name)
  end

  @aliases = []
end

Instance Attribute Details

#blockObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/parameter/value.rb', line 10

def block
  @block
end

#eventObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/puppet/parameter/value.rb', line 9

def event
  @event
end

#invalidate_refreshesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/parameter/value.rb', line 10

def invalidate_refreshes
  @invalidate_refreshes
end

#methodObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/parameter/value.rb', line 10

def method
  @method
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/puppet/parameter/value.rb', line 9

def name
  @name
end

#optionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/puppet/parameter/value.rb', line 9

def options
  @options
end

#required_featuresObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
# File 'lib/puppet/parameter/value.rb', line 10

def required_features
  @required_features
end

Instance Method Details

#alias(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Adds an alias for this value. Makes the given name be an alias for this acceptable value.

Parameters:

  • name (Symbol)

    the additional alias this value should be known as



17
18
19
# File 'lib/puppet/parameter/value.rb', line 17

def alias(name)
  @aliases << convert(name)
end

#aliasesArray<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all aliases (or an empty array).

Returns:

  • (Array<Symbol>)

    Returns all aliases (or an empty array).



24
25
26
# File 'lib/puppet/parameter/value.rb', line 24

def aliases
  @aliases.dup
end

#match?(value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if the given value matches the acceptance rules (literal value, regular expression, or one of the aliases.

Returns:



56
57
58
59
60
61
62
# File 'lib/puppet/parameter/value.rb', line 56

def match?(value)
  if regex?
    return true if name =~ value.to_s
  else
    return(name == convert(value) ? true : @aliases.include?(convert(value)))
  end
end

#regex?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether the accepted value is a regular expression or not.

Returns:

  • (Boolean)

    whether the accepted value is a regular expression or not.



67
68
69
# File 'lib/puppet/parameter/value.rb', line 67

def regex?
  @name.is_a?(Regexp)
end