Class: Renderer::Entities::Base
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#references ⇒ Object
Returns the value of attribute references.
Instance Method Summary collapse
- #class? ⇒ Boolean
- #def? ⇒ Boolean
- #full_path ⇒ Object
-
#initialize(parent, name) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
- #module? ⇒ Boolean
- #register_reference(ref) ⇒ Object
- #root ⇒ Object
- #root? ⇒ Boolean
- #static? ⇒ Boolean
- #to_s ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(parent, name) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 |
# File 'lib/renderer/entities/base.rb', line 8 def initialize(parent, name) @parent = parent @name = name @references = [] end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/renderer/entities/base.rb', line 6 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent.
6 7 8 |
# File 'lib/renderer/entities/base.rb', line 6 def parent @parent end |
#references ⇒ Object
Returns the value of attribute references.
6 7 8 |
# File 'lib/renderer/entities/base.rb', line 6 def references @references end |
Instance Method Details
#class? ⇒ Boolean
18 |
# File 'lib/renderer/entities/base.rb', line 18 def class? = type == :class |
#def? ⇒ Boolean
20 |
# File 'lib/renderer/entities/base.rb', line 20 def def? = type == :def |
#full_path ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/renderer/entities/base.rb', line 45 def full_path parents = [] parent = self.parent until parent.root? parents << parent parent = parent.parent end parents.reverse! parents << self end |
#inspect ⇒ Object
35 |
# File 'lib/renderer/entities/base.rb', line 35 def inspect = "#<#{self.class.name}:#{object_id_hex} #{name}>" |
#module? ⇒ Boolean
16 |
# File 'lib/renderer/entities/base.rb', line 16 def module? = type == :module |
#register_reference(ref) ⇒ Object
41 42 43 |
# File 'lib/renderer/entities/base.rb', line 41 def register_reference(ref) @references << ref end |
#root ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/renderer/entities/base.rb', line 24 def root obj = self loop do return obj if obj.parent.nil? obj = obj.parent end raise "Orphaned object" end |
#root? ⇒ Boolean
39 |
# File 'lib/renderer/entities/base.rb', line 39 def root? = module? && parent.nil? |
#static? ⇒ Boolean
22 |
# File 'lib/renderer/entities/base.rb', line 22 def static? = type == :sdef |
#to_s ⇒ Object
37 |
# File 'lib/renderer/entities/base.rb', line 37 def to_s = inspect |
#type ⇒ Object
14 |
# File 'lib/renderer/entities/base.rb', line 14 def type = raise NotImplementedError, "Classes inheriting Entities::Base must implement #type" |