Class: Rsxml::Visitor::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rsxml/visitor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(initial_ns_bindings = nil) ⇒ Context

Returns a new instance of Context.



11
12
13
14
15
16
17
# File 'lib/rsxml/visitor.rb', line 11

def initialize(initial_ns_bindings = nil)
  @ns_stack=[]
  @ns_stack << initial_ns_bindings if initial_ns_bindings
  @node_stack=[]
  @prev_siblings=[]
  @sibling_stack=[]
end

Instance Attribute Details

#node_stackObject (readonly)

Returns the value of attribute node_stack.



9
10
11
# File 'lib/rsxml/visitor.rb', line 9

def node_stack
  @node_stack
end

#ns_stackObject (readonly)

Returns the value of attribute ns_stack.



8
9
10
# File 'lib/rsxml/visitor.rb', line 8

def ns_stack
  @ns_stack
end

#prev_siblingsObject (readonly)

Returns the value of attribute prev_siblings.



10
11
12
# File 'lib/rsxml/visitor.rb', line 10

def prev_siblings
  @prev_siblings
end

Instance Method Details

#pop_nodeObject



25
26
27
28
29
# File 'lib/rsxml/visitor.rb', line 25

def pop_node
  n = node_stack.pop
  @prev_siblings = @sibling_stack.pop
  @prev_siblings << n
end

#processed_node(node) ⇒ Object



31
32
33
# File 'lib/rsxml/visitor.rb', line 31

def processed_node(node)
  @prev_siblings << node
end

#push_node(node) ⇒ Object



19
20
21
22
23
# File 'lib/rsxml/visitor.rb', line 19

def push_node(node)
  node_stack.push(node)
  @sibling_stack.push(@prev_siblings)
  @prev_siblings=[]
end