Sha256: 4456eabca7df7937d00053a15bdaa0234e3eb61d663d3b35e54b85a596fdcfb9

Contents?: true

Size: 1.83 KB

Versions: 174

Compression:

Stored size: 1.83 KB

Contents

#!/usr/bin/env ruby

#--
# Copyright 2004 by Jim Weirich (jim@weirichhouse.org).
# All rights reserved.

# Permission is granted for use, copying, modification, distribution,
# and distribution of modified versions of this work as long as the
# above copyright notice is included.
#++

require 'builder/xmlmarkup'

module Builder

  # Create a series of SAX-like XML events (e.g. start_tag, end_tag)
  # from the markup code.  XmlEvent objects are used in a way similar
  # to XmlMarkup objects, except that a series of events are generated
  # and passed to a handler rather than generating character-based
  # markup.
  #
  # Usage:
  #   xe = Builder::XmlEvents.new(handler)
  #   xe.title("HI")    # Sends start_tag/end_tag/text messages to the handler.
  #
  # Indentation may also be selected by providing value for the
  # indentation size and initial indentation level.
  #
  #   xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level)
  #
  # == XML Event Handler
  #
  # The handler object must expect the following events.
  #
  # [<tt>start_tag(tag, attrs)</tt>]
  #     Announces that a new tag has been found.  +tag+ is the name of
  #     the tag and +attrs+ is a hash of attributes for the tag.
  #
  # [<tt>end_tag(tag)</tt>]
  #     Announces that an end tag for +tag+ has been found.
  #
  # [<tt>text(text)</tt>]
  #     Announces that a string of characters (+text+) has been found.
  #     A series of characters may be broken up into more than one
  #     +text+ call, so the client cannot assume that a single
  #     callback contains all the text data.
  #
  class XmlEvents < XmlMarkup
    def text!(text)
      @target.text(text)
    end

    def _start_tag(sym, attrs, end_too=false)
      @target.start_tag(sym, attrs)
      _end_tag(sym) if end_too
    end

    def _end_tag(sym)
      @target.end_tag(sym)
    end
  end

end

Version data entries

174 entries across 140 versions & 23 rubygems

Version Path
p8-castronaut-0.6.1.1 vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
relevance-castronaut-0.6.0 vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
relevance-castronaut-0.6.1 vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
relevance-castronaut-0.7.4 vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
relevance-castronaut-0.7.5 vendor/activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.31 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.31 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.30 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.30 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.29 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.29 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.28 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.28 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.27 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.27 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.26 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.26 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.25 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.25 etc/isolate/ruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
depengine-0.0.24 etc/isolate/jruby-1.8/gems/activesupport-2.3.8/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb