class PuppetStrings::Yard::CodeObjects::Type
Implements the Puppet resource type code object.
Attributes
Public Class Methods
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
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
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
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
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
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