Class: Bemer::Tree::BaseNode

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/bemer/tree/base_node.rb

Direct Known Subclasses

Node, TextNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tree, block = '', element = nil, **options, &content) ⇒ BaseNode

Returns a new instance of BaseNode.



15
16
17
18
19
20
# File 'lib/bemer/tree/base_node.rb', line 15

def initialize(tree, block = '', element = nil, **options, &content)
  @entity         = Entity.new(block, element, options, &content)
  @entity_builder = EntityBuilder.new(block, element, options, &content)
  @renderer       = Renderer.new
  @tree           = tree
end

Instance Attribute Details

#entityObject (readonly)

Returns the value of attribute entity.



10
11
12
# File 'lib/bemer/tree/base_node.rb', line 10

def entity
  @entity
end

#entity_builderObject (readonly)

Returns the value of attribute entity_builder.



10
11
12
# File 'lib/bemer/tree/base_node.rb', line 10

def entity_builder
  @entity_builder
end

#treeObject (readonly)

Returns the value of attribute tree.



10
11
12
# File 'lib/bemer/tree/base_node.rb', line 10

def tree
  @tree
end

Instance Method Details

#need_replace?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/bemer/tree/base_node.rb', line 34

def need_replace?
  false
end


28
29
30
31
32
# File 'lib/bemer/tree/base_node.rb', line 28

def print(level = 0)
  prefix = '   ' * level

  puts [prefix, name, "(#{object_id})"].join
end

#renderObject



22
23
24
25
26
# File 'lib/bemer/tree/base_node.rb', line 22

def render
  entity_builder.content = capture_content

  renderer.render(entity_builder)
end