Class: PuppetStrings::Yard::CodeObjects::Type::Parameter
- Inherits:
-
Object
- Object
- PuppetStrings::Yard::CodeObjects::Type::Parameter
- Defined in:
- lib/puppet-strings/yard/code_objects/type.rb
Overview
Represents a resource type parameter.
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#data_type ⇒ Object
Returns the value of attribute data_type.
-
#default ⇒ Object
Returns the value of attribute default.
-
#docstring ⇒ Object
Returns the value of attribute docstring.
-
#isnamevar ⇒ Object
Returns the value of attribute isnamevar.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#required_features ⇒ Object
Returns the value of attribute required_features.
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
-
#add(value) ⇒ void
Adds a value to the parameter or property.
-
#alias(new, old) ⇒ void
Aliases a value to another value.
-
#initialize(name, docstring = nil) ⇒ Parameter
constructor
Initializes a resource type parameter or property.
-
#to_hash ⇒ Hash
Converts the parameter to a hash representation.
Constructor Details
#initialize(name, docstring = nil) ⇒ Parameter
Initializes a resource type parameter or property.
32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 32 def initialize(name, docstring = nil) @name = name @docstring = docstring || '' @values = [] @data_type = [] @aliases = {} @isnamevar = false @default = nil end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
26 27 28 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 26 def aliases @aliases end |
#data_type ⇒ Object
Returns the value of attribute data_type.
27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 27 def data_type @data_type end |
#default ⇒ Object
Returns the value of attribute default.
27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 27 def default @default end |
#docstring ⇒ Object
Returns the value of attribute docstring.
27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 27 def docstring @docstring end |
#isnamevar ⇒ Object
Returns the value of attribute isnamevar.
27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 27 def isnamevar @isnamevar end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
26 27 28 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 26 def name @name end |
#required_features ⇒ Object
Returns the value of attribute required_features.
27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 27 def required_features @required_features end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
26 27 28 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 26 def values @values end |
Instance Method Details
#add(value) ⇒ void
This method returns an undefined value.
Adds a value to the parameter or property.
45 46 47 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 45 def add(value) @values << value end |
#alias(new, old) ⇒ void
This method returns an undefined value.
Aliases a value to another value.
53 54 55 56 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 53 def alias(new, old) @values << new unless @values.include? new @aliases[new] = old end |
#to_hash ⇒ Hash
Converts the parameter to a hash representation.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 60 def to_hash hash = {} hash[:name] = name hash[:description] = docstring unless docstring.empty? hash[:values] = values unless values.empty? hash[:data_type] = data_type unless data_type.empty? hash[:aliases] = aliases unless aliases.empty? hash[:isnamevar] = true if isnamevar hash[:required_features] = required_features if required_features hash[:default] = default if default hash end |