class Saxerator::Parser::Accumulator

Public Class Methods

new(config, block) click to toggle source
# File lib/saxerator/parser/accumulator.rb, line 4
def initialize(config, block)
  @stack = []
  @config = config
  @block = block
end

Public Instance Methods

accumulating?() click to toggle source
# File lib/saxerator/parser/accumulator.rb, line 27
def accumulating?
  !@stack.empty?
end
characters(string) click to toggle source
# File lib/saxerator/parser/accumulator.rb, line 23
def characters(string)
  @stack[-1].add_node(string) unless string.strip.empty?
end
end_element(_) click to toggle source
# File lib/saxerator/parser/accumulator.rb, line 14
def end_element(_)
  if @stack.size > 1
    last = @stack.pop
    @stack[-1].add_node last
  else
    @block.call(@stack.pop.block_variable)
  end
end
start_element(name, attrs = []) click to toggle source
# File lib/saxerator/parser/accumulator.rb, line 10
def start_element(name, attrs = [])
  @stack.push @config.output_type.new(@config, name, Hash[attrs])
end