Class: Puppet::Parameter::Value

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

Overview

An individual Value class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Value

Returns a new instance of Value.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/vendor/puppet/parameter/value.rb', line 23

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 = []

  @call = :instead
end

Instance Attribute Details

#blockObject

Returns the value of attribute block.



6
7
8
# File 'lib/vendor/puppet/parameter/value.rb', line 6

def block
  @block
end

#callObject

Returns the value of attribute call.



6
7
8
# File 'lib/vendor/puppet/parameter/value.rb', line 6

def call
  @call
end

#eventObject

Returns the value of attribute event.



5
6
7
# File 'lib/vendor/puppet/parameter/value.rb', line 5

def event
  @event
end

#methodObject

Returns the value of attribute method.



6
7
8
# File 'lib/vendor/puppet/parameter/value.rb', line 6

def method
  @method
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/vendor/puppet/parameter/value.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/vendor/puppet/parameter/value.rb', line 5

def options
  @options
end

#required_featuresObject

Returns the value of attribute required_features.



6
7
8
# File 'lib/vendor/puppet/parameter/value.rb', line 6

def required_features
  @required_features
end

Instance Method Details

#alias(name) ⇒ Object

Add an alias for this value.



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

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

#aliasesObject

Return all aliases.



14
15
16
# File 'lib/vendor/puppet/parameter/value.rb', line 14

def aliases
  @aliases.dup
end

#match?(value) ⇒ Boolean

Does a provided value match our value?

Returns:

  • (Boolean)


38
39
40
41
42
43
44
# File 'lib/vendor/puppet/parameter/value.rb', line 38

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

Is our value a regex?

Returns:

  • (Boolean)


47
48
49
# File 'lib/vendor/puppet/parameter/value.rb', line 47

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