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.
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/puppet/parameter/value.rb', line 42 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.
12 13 14 |
# File 'lib/puppet/parameter/value.rb', line 12 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.
11 12 13 |
# File 'lib/puppet/parameter/value.rb', line 11 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.
12 13 14 |
# File 'lib/puppet/parameter/value.rb', line 12 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.
12 13 14 |
# File 'lib/puppet/parameter/value.rb', line 12 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.
11 12 13 |
# File 'lib/puppet/parameter/value.rb', line 11 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.
11 12 13 |
# File 'lib/puppet/parameter/value.rb', line 11 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.
12 13 14 |
# File 'lib/puppet/parameter/value.rb', line 12 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.
19 20 21 |
# File 'lib/puppet/parameter/value.rb', line 19 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).
26 27 28 |
# File 'lib/puppet/parameter/value.rb', line 26 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.
58 59 60 61 62 63 64 |
# File 'lib/puppet/parameter/value.rb', line 58 def match?(value) if regex? true if name =~ value.to_s else (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.
69 70 71 |
# File 'lib/puppet/parameter/value.rb', line 69 def regex? @name.is_a?(Regexp) end |