Class: Puppet::Parameter::Value Private
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.
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
- #block ⇒ Object private
- #event ⇒ Object private
- #invalidate_refreshes ⇒ Object private
- #method ⇒ Object private
- #name ⇒ Object readonly private
- #options ⇒ Object readonly private
- #required_features ⇒ Object private
Instance Method Summary collapse
-
#alias(name) ⇒ Object
private
Adds an alias for this value.
-
#aliases ⇒ Array<Symbol>
private
Returns all aliases (or an empty array).
-
#initialize(name) ⇒ Value
constructor
private
Initializes the instance with a literal accepted value, or a regular expression.
-
#match?(value) ⇒ Boolean
private
Checks if the given value matches the acceptance rules (literal value, regular expression, or one of the aliases..
-
#regex? ⇒ Boolean
private
Whether the accepted value is a regular expression or not.
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.
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
#block ⇒ 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.
10 11 12 |
# File 'lib/puppet/parameter/value.rb', line 10 def block @block end |
#event ⇒ 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.
9 10 11 |
# File 'lib/puppet/parameter/value.rb', line 9 def event @event end |
#invalidate_refreshes ⇒ 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.
10 11 12 |
# File 'lib/puppet/parameter/value.rb', line 10 def invalidate_refreshes @invalidate_refreshes end |
#method ⇒ 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.
10 11 12 |
# File 'lib/puppet/parameter/value.rb', line 10 def method @method end |
#name ⇒ Object (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 |
#options ⇒ Object (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 end |
#required_features ⇒ 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.
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.
17 18 19 |
# File 'lib/puppet/parameter/value.rb', line 17 def alias(name) @aliases << convert(name) end |
#aliases ⇒ Array<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).
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.
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.
67 68 69 |
# File 'lib/puppet/parameter/value.rb', line 67 def regex? @name.is_a?(Regexp) end |