Class: PuppetStrings::Yard::CodeObjects::Type
- Inherits:
-
Base
- Object
- YARD::CodeObjects::NamespaceObject
- Base
- PuppetStrings::Yard::CodeObjects::Type
- Defined in:
- lib/puppet-strings/yard/code_objects/type.rb
Overview
Implements the Puppet resource type code object.
Defined Under Namespace
Classes: Feature, Parameter, Property
Instance Attribute Summary collapse
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#add_feature(feature) ⇒ void
Adds a feature to the resource type.
-
#add_parameter(parameter) ⇒ void
Adds a parameter to the resource type.
-
#add_property(property) ⇒ void
Adds a property to the resource type.
-
#initialize(name) ⇒ void
constructor
Initializes a new resource type.
-
#to_hash ⇒ Hash
Converts the code object to a hash representation.
-
#type ⇒ Object
Gets the type of the code object.
Methods inherited from Base
Constructor Details
#initialize(name) ⇒ void
Initializes a new resource type.
103 104 105 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 103 def initialize(name) super(PuppetStrings::Yard::CodeObjects::Types.instance, name) end |
Instance Attribute Details
#features ⇒ Object (readonly)
Returns the value of attribute features.
98 99 100 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 98 def features @features end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
98 99 100 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 98 def parameters @parameters end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
98 99 100 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 98 def properties @properties end |
Instance Method Details
#add_feature(feature) ⇒ void
This method returns an undefined value.
Adds a feature to the resource type.
132 133 134 135 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 132 def add_feature(feature) @features ||= [] @features << feature end |
#add_parameter(parameter) ⇒ void
This method returns an undefined value.
Adds a parameter to the resource type
116 117 118 119 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 116 def add_parameter(parameter) @parameters ||= [] @parameters << parameter end |
#add_property(property) ⇒ void
This method returns an undefined value.
Adds a property to the resource type
124 125 126 127 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 124 def add_property(property) @properties ||= [] @properties << property end |
#to_hash ⇒ Hash
Converts the code object to a hash representation.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 139 def to_hash hash = {} hash[:name] = name hash[:file] = file hash[:line] = line hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) hash[:properties] = properties.map(&:to_hash) if properties && !properties.empty? hash[:parameters] = parameters.map(&:to_hash) if parameters && !parameters.empty? hash[:features] = features.map(&:to_hash) if features && !features.empty? hash end |
#type ⇒ Object
Gets the type of the code object.
109 110 111 |
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 109 def type :puppet_type end |