class PuppetStrings::Yard::CodeObjects::Class
Implements the Puppet
class code object.
Attributes
parameters[R]
statement[R]
Public Class Methods
new(statement)
click to toggle source
Initializes a Puppet
class code object. @param [PuppetStrings::Parsers::ClassStatement] statement The class statement that was parsed. @return [void]
Calls superclass method
PuppetStrings::Yard::CodeObjects::Base::new
# File lib/puppet-strings/yard/code_objects/class.rb, line 28 def initialize(statement) @statement = statement @parameters = statement.parameters.map { |p| [p.name, p.value] } super(PuppetStrings::Yard::CodeObjects::Classes.instance, statement.name) end
Public Instance Methods
source()
click to toggle source
Gets the source of the code object. @return Returns the source of the code object.
# File lib/puppet-strings/yard/code_objects/class.rb, line 42 def source @statement.source end
to_hash()
click to toggle source
Converts the code object to a hash representation. @return [Hash] Returns a hash representation of the code object.
# File lib/puppet-strings/yard/code_objects/class.rb, line 48 def to_hash hash = {} hash[:name] = name hash[:file] = file hash[:line] = line hash[:inherits] = statement.parent_class if statement.parent_class hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) defaults = Hash[*parameters.reject { |p| p[1].nil? }.flatten] hash[:defaults] = defaults unless defaults.nil? || defaults.empty? hash[:source] = source unless source.nil? || source.empty? hash end
type()
click to toggle source
Gets the type of the code object. @return Returns the type of the code object.
# File lib/puppet-strings/yard/code_objects/class.rb, line 36 def type :puppet_class end