Sha256: be8ef4adc38c0fcffaecc58ee8877677be53d5354436b9becdbc1ce394e6d6b4

Contents?: true

Size: 563 Bytes

Versions: 1

Compression:

Stored size: 563 Bytes

Contents

require "nokogiri"

module Burlap
  class Listener < Nokogiri::XML::SAX::Document
    attr_accessor :result

    def initialize
      @result = nil
      @open = []
    end

    def start_element name, attrs=[]
      @open.push BaseTag.new(:name => name)
    end

    def characters contents
      @open.last.value += contents if @open.last
    end

    def end_element name
      last = @open.pop
      if @open.empty?
        @result = last.to_ruby
      else
        @open.last.children.push last
      end
    end

  private
    attr_writer :data

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
burlap-1.0.0 lib/burlap/listener.rb