Class: PuppetStrings::Yard::CodeObjects::Plan
- Inherits:
-
Base
- Object
- YARD::CodeObjects::NamespaceObject
- Base
- PuppetStrings::Yard::CodeObjects::Plan
- Defined in:
- lib/puppet-strings/yard/code_objects/plan.rb
Instance Attribute Summary collapse
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#statement ⇒ Object
readonly
Returns the value of attribute statement.
Instance Method Summary collapse
-
#initialize(statement) ⇒ void
constructor
Initializes a Puppet plan code 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 Puppet plan code object.
25 26 27 28 29 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 25 def initialize(statement) @statement = statement @parameters = statement.parameters.map { |p| [p.name, p.value] } super(PuppetStrings::Yard::CodeObjects::Plans.instance, statement.name) end |
Instance Attribute Details
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
20 21 22 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 20 def parameters @parameters end |
#statement ⇒ Object (readonly)
Returns the value of attribute statement.
19 20 21 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 19 def statement @statement end |
Instance Method Details
#source ⇒ Object
Gets the source of the code object.
39 40 41 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 39 def source @statement.source end |
#to_hash ⇒ Hash
Converts the code object to a hash representation.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 45 def to_hash hash = {} hash[:name] = name hash[:file] = file hash[:line] = line hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) defaults = Hash[*parameters.select{ |p| !p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.empty? hash[:source] = source unless source && source.empty? hash end |
#type ⇒ Object
Gets the type of the code object.
33 34 35 |
# File 'lib/puppet-strings/yard/code_objects/plan.rb', line 33 def type :puppet_plan end |