class PuppetStrings::Yard::CodeObjects::Type

Implements the Puppet resource type code object.

Attributes

features[R]
parameters[R]
properties[R]

Public Class Methods

new(name) click to toggle source

Initializes a new resource type. @param [String] name The resource type name. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 99
def initialize(name)
  super(PuppetStrings::Yard::CodeObjects::Types.instance, name)
end

Public Instance Methods

add_feature(feature) click to toggle source

Adds a feature to the resource type. @param [PuppetStrings::Yard::CodeObjects::Type::Feature] feature The feature to add. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 128
def add_feature(feature)
  @features ||= []
  @features << feature
end
add_parameter(parameter) click to toggle source

Adds a parameter to the resource type @param [PuppetStrings::Yard::CodeObjects::Type::Parameter] parameter The parameter to add. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 112
def add_parameter(parameter)
  @parameters ||= []
  @parameters << parameter
end
add_property(property) click to toggle source

Adds a property to the resource type @param [PuppetStrings::Yard::CodeObjects::Type::Property] property The property to add. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 120
def add_property(property)
  @properties ||= []
  @properties << property
end
to_hash() click to toggle source

Converts the code object to a hash representation. @return [Hash] Returns a hash representation of the code object.

# File lib/puppet-strings/yard/code_objects/type.rb, line 135
def to_hash
  hash = {}
  hash[:name] = name
  hash[:file] = file
  hash[:line] = line
  hash[:docstring] = PuppetStrings::Json.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() click to toggle source

Gets the type of the code object. @return Returns the type of the code object.

# File lib/puppet-strings/yard/code_objects/type.rb, line 105
def type
  :puppet_type
end