class PuppetStrings::Yard::CodeObjects::Type::Parameter

Represents a resource type parameter.

Attributes

aliases[R]
data_type[RW]
default[RW]
docstring[RW]
isnamevar[RW]
name[R]
required_features[RW]
values[R]

Public Class Methods

new(name, docstring = nil) click to toggle source

Initializes a resource type parameter or property. @param [String] name The name of the parameter or property. @param [String] docstring The docstring for the parameter or property.s

# File lib/puppet-strings/yard/code_objects/type.rb, line 32
def initialize(name, docstring = nil)
  @name = name
  @docstring = docstring || ''
  @values = []
  @data_type = []
  @aliases = {}
  @isnamevar = false
  @default = nil
end

Public Instance Methods

add(value) click to toggle source

Adds a value to the parameter or property. @param [String] value The value to add. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 45
def add(value)
  @values << value
end
alias(new, old) click to toggle source

Aliases a value to another value. @param [String] new The new (alias) value. @param [String] old The old (existing) value. @return [void]

# File lib/puppet-strings/yard/code_objects/type.rb, line 53
def alias(new, old)
  @values << new unless @values.include? new
  @aliases[new] = old
end
to_hash() click to toggle source

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

# File lib/puppet-strings/yard/code_objects/type.rb, line 60
def to_hash
  hash = {}
  hash[:name] = name
  hash[:description] = docstring unless docstring.empty?
  hash[:values] = values unless values.empty?
  hash[:data_type] = data_type unless data_type.empty?
  hash[:aliases] = aliases unless aliases.empty?
  hash[:isnamevar] = true if isnamevar
  hash[:required_features] = required_features if required_features
  hash[:default] = default if default
  hash
end