Class: ReFe::ModuleNode

Inherits:
Object
  • Object
show all
Defined in:
lib/refe/inheritancegraph.rb

Direct Known Subclasses

ClassNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ModuleNode

Returns a new instance of ModuleNode.



72
73
74
75
# File 'lib/refe/inheritancegraph.rb', line 72

def initialize( name )
  @name = name
  @included = []
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



77
78
79
# File 'lib/refe/inheritancegraph.rb', line 77

def name
  @name
end

Instance Method Details

#ancestorsObject



87
88
89
90
91
92
93
# File 'lib/refe/inheritancegraph.rb', line 87

def ancestors
  result = [self]
  @included.each do |mod|
    result.concat mod.ancestors
  end
  result.uniq   # uniq is ReFe specific
end

#include(mod) ⇒ Object



83
84
85
# File 'lib/refe/inheritancegraph.rb', line 83

def include( mod )
  @included.unshift mod
end

#inspectObject



79
80
81
# File 'lib/refe/inheritancegraph.rb', line 79

def inspect
  "\#<#{self.class} #{@name}>"
end