Class: PuppetStrings::Yard::CodeObjects::Type

Inherits:
Base
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Base

new

Constructor Details

#initialize(name) ⇒ void

Initializes a new resource type.

Parameters:

  • name (String)

    The resource type name.



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

#featuresObject (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

#parametersObject (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

#propertiesObject (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.

Parameters:



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

Parameters:



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

Parameters:



124
125
126
127
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 124

def add_property(property)
  @properties ||= []
  @properties << property
end

#to_hashHash

Converts the code object to a hash representation.

Returns:

  • (Hash)

    Returns a hash representation of the code object.



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

#typeObject

Gets the type of the code object.

Returns:

  • Returns 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