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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#aliases ⇒ Object
readonly
Returns the value of attribute aliases.
-
#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.
-
#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.
29 30 31 32 33 34 35 36 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 29 def initialize(name, docstring = nil) @name = name @docstring = docstring || '' @values = [] @aliases = {} @isnamevar = false @default = nil end |
Instance Attribute Details
#aliases ⇒ Object (readonly)
Returns the value of attribute aliases.
23 24 25 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 23 def aliases @aliases end |
#default ⇒ Object
Returns the value of attribute default.
24 25 26 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 24 def default @default end |
#docstring ⇒ Object
Returns the value of attribute docstring.
24 25 26 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 24 def docstring @docstring end |
#isnamevar ⇒ Object
Returns the value of attribute isnamevar.
24 25 26 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 24 def isnamevar @isnamevar end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 23 def name @name end |
#values ⇒ Object (readonly)
Returns the value of attribute values.
23 24 25 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 23 def values @values end |
Instance Method Details
#add(value) ⇒ void
This method returns an undefined value.
Adds a value to the parameter or property.
41 42 43 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 41 def add(value) @values << value end |
#alias(new, old) ⇒ void
This method returns an undefined value.
Aliases a value to another value.
49 50 51 52 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 49 def alias(new, old) @values << new unless @values.include? new @aliases[new] = old end |
#to_hash ⇒ Hash
Converts the parameter to a hash representation.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 56 def to_hash hash = {} hash[:name] = name hash[:description] = docstring unless docstring.empty? hash[:values] = values unless values.empty? hash[:aliases] = aliases unless aliases.empty? hash[:isnamevar] = true if isnamevar hash[:default] = default if default hash end |