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

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet-strings/yard/code_objects/type.rb

Overview

Represents a resource type feature.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, docstring) ⇒ Feature

Initializes a new feature.

Parameters:

  • name (String)

    The name of the feature.

  • docstring (String)

    The docstring of the feature.



88
89
90
91
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 88

def initialize(name, docstring)
  @name = name
  @docstring = PuppetStrings::Yard::Util.scrub_string(docstring).tr("\n", ' ')
end

Instance Attribute Details

#docstringObject (readonly)

Returns the value of attribute docstring.



83
84
85
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 83

def docstring
  @docstring
end

#nameObject (readonly)

Returns the value of attribute name.



83
84
85
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 83

def name
  @name
end

Instance Method Details

#to_hashHash

Converts the feature to a hash representation.

Returns:

  • (Hash)

    Returns a hash representation of the feature.



95
96
97
98
99
100
# File 'lib/puppet-strings/yard/code_objects/type.rb', line 95

def to_hash
  hash = {}
  hash[:name] = name
  hash[:description] = docstring unless docstring.empty?
  hash
end