Class: PuppetStrings::Yard::CodeObjects::Task

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

Overview

Implements the Puppet task code object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

new

Constructor Details

#initialize(statement) ⇒ void

Initializes a JSON task code object.

Parameters:

  • statement

    TaskStatement object



28
29
30
31
32
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 28

def initialize(statement)
  @name = statement.name
  @statement = statement
  super(PuppetStrings::Yard::CodeObjects::Tasks.instance, name)
end

Instance Attribute Details

#statementObject (readonly)

Returns the value of attribute statement.



23
24
25
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 23

def statement
  @statement
end

Instance Method Details

#parametersObject



46
47
48
49
50
51
52
53
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 46

def parameters
  statement.parameters.map do |name, props|
    { name: name.to_s,
      tag_name: 'param',
      text: props['description'] || '',
      types: [props['type']] || '' }
  end
end

#sourceObject

Gets the source of the code object.

Returns:

  • Returns the source of the code object.



42
43
44
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 42

def source
  @statement.source
end

#to_hashHash

Converts the code object to a hash representation.

Returns:

  • (Hash)

    Returns a hash representation of the code object.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 57

def to_hash
  { name: name.to_s,
    file: statement.file,
    line: statement.line,
    docstring: {
      text: statement.docstring,
      tags: parameters
    },
    source: statement.source,
    supports_noop: statement.json['supports_noop'] || false,
    input_method: statement.json['input_method'] }
end

#typeObject

Gets the type of the code object.

Returns:

  • Returns the type of the code object.



36
37
38
# File 'lib/puppet-strings/yard/code_objects/task.rb', line 36

def type
  :puppet_task
end