Class: PDoc::Models::Class

Inherits:
Entity show all
Includes:
Container
Defined in:
lib/pdoc/models/class.rb

Instance Attribute Summary collapse

Attributes inherited from Entity

#alias

Attributes inherited from Base

#description, #file, #id, #line_number, #parent, #type

Instance Method Summary collapse

Methods included from Container

#children, #children?, #class_methods, #class_methods?, #class_properties, #class_properties?, #classes, #classes?, #constants, #constants?, #included_mixins, #included_mixins?, #instance_methods, #instance_methods?, #instance_properties, #instance_properties?, #mixins, #mixins?, #namespaces, #namespaces?, #utilities, #utilities?

Methods inherited from Entity

#<=>, #alias?, #aliases, #aliases?, #methodized?, #signature, #signatures, #signatures?, #src_code_href

Methods inherited from Base

#ancestor_of?, #deprecated?, #descendant_of?, #doc_href, #full_name, #initialize, #inspect, instantiate, #name, #normalized_name, #register_on, #short_description, #to_json, #url

Constructor Details

This class inherits a constructor from PDoc::Models::Base

Instance Attribute Details

#constructorObject

Returns the value of attribute constructor.



5
6
7
# File 'lib/pdoc/models/class.rb', line 5

def constructor
  @constructor
end

#superclassObject

Returns the value of attribute superclass.



6
7
8
# File 'lib/pdoc/models/class.rb', line 6

def superclass
  @superclass
end

Instance Method Details

#attach_to_parent(parent) ⇒ Object



7
8
9
# File 'lib/pdoc/models/class.rb', line 7

def attach_to_parent(parent)
  parent.classes << self
end

#subclassesObject



11
12
13
# File 'lib/pdoc/models/class.rb', line 11

def subclasses
  @subclasses ||= []
end

#subclasses?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/pdoc/models/class.rb', line 15

def subclasses?
  @subclasses && !@subclasses.empty?
end

#to_hashObject



19
20
21
22
23
24
25
# File 'lib/pdoc/models/class.rb', line 19

def to_hash
  super.merge({
    :superclass => superclass,
    :constructor => constructor,
    :subclasses => subclasses.map { |obj| obj.id }
  })
end