Class: PuppetStrings::Yard::CodeObjects::Task
- Inherits:
-
Base
- Object
- YARD::CodeObjects::NamespaceObject
- Base
- PuppetStrings::Yard::CodeObjects::Task
- Defined in:
- lib/puppet-strings/yard/code_objects/task.rb
Overview
Implements the Puppet task code object.
Instance Attribute Summary collapse
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
-
#initialize(statement) ⇒ void
constructor
Initializes a JSON task code object.
- #parameters ⇒ Object
-
#source ⇒ Object
Gets the source of the code object.
-
#to_hash ⇒ Hash
Converts the code object to a hash representation.
-
#type ⇒ Object
Gets the type of the code object.
Methods inherited from Base
Constructor Details
#initialize(statement) ⇒ void
Initializes a JSON task code 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
#statement ⇒ Object (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
#parameters ⇒ Object
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 |
#source ⇒ Object
Gets 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_hash ⇒ Hash
Converts the code object to a hash representation.
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 |
#type ⇒ Object
Gets 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 |