Class: PuppetStrings::Yard::Parsers::Puppet::FunctionStatement

Inherits:
ParameterizedStatement show all
Defined in:
lib/puppet-strings/yard/parsers/puppet/statement.rb

Overview

Implements the Puppet function statement.

Constant Summary

Constants inherited from Statement

Statement::COMMENT_REGEX

Instance Attribute Summary collapse

Attributes inherited from ParameterizedStatement

#parameters

Attributes inherited from Statement

#comments_range, #docstring, #file, #line, #source

Instance Method Summary collapse

Methods inherited from Statement

#comments, #comments_hash_flag, #extract_docstring, #show

Constructor Details

#initialize(object, file) ⇒ FunctionStatement

Initializes the Puppet function statement.

Parameters:

  • object (Puppet::Pops::Model::FunctionDefinition)

    The model object for the function statement.

  • file (String)

    The file containing the statement.



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/puppet-strings/yard/parsers/puppet/statement.rb', line 142

def initialize(object, file)
  super(object, file)
  @name = object.name
  if object.respond_to? :return_type
    type = object.return_type
    if type
      adapter = ::Puppet::Pops::Adapters::SourcePosAdapter.adapt(type)
      @type = adapter.extract_text.gsub('>> ', '')
    end
  end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



136
137
138
# File 'lib/puppet-strings/yard/parsers/puppet/statement.rb', line 136

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



137
138
139
# File 'lib/puppet-strings/yard/parsers/puppet/statement.rb', line 137

def type
  @type
end