Class: H2o::Nodelist

Inherits:
Node show all
Defined in:
lib/h2o/nodes.rb

Overview

Nodelist

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser, position = 0) ⇒ Nodelist

Returns a new instance of Nodelist.



17
18
19
20
# File 'lib/h2o/nodes.rb', line 17

def initialize(parser, position = 0)
 @parser = parser
 @stack = []  
end

Instance Attribute Details

#parserObject (readonly)

Returns the value of attribute parser.



15
16
17
# File 'lib/h2o/nodes.rb', line 15

def parser
  @parser
end

Instance Method Details

#<<(node) ⇒ Object



33
34
35
# File 'lib/h2o/nodes.rb', line 33

def <<(node)
  @stack << node
end

#lengthObject



37
38
39
# File 'lib/h2o/nodes.rb', line 37

def length
  @stack.length
end

#render(context = {}, stream = false) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/h2o/nodes.rb', line 22

def render(context = {}, stream = false)
  stream = [] unless stream
  context = Context.new(context) if context.is_a? Hash

  @stack.each do |node|
    node.render(context, stream)
  end
  
  stream.join
end