Class: Builder::XmlEvents

Inherits:
XmlMarkup show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb

Overview

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(hander)
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.

start_tag(tag, attrs)

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.

end_tag(tag)

Announces that an end tag for tag has been found.

text(text)

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.

Instance Method Summary collapse

Methods inherited from XmlMarkup

#cdata!, #cdata_value!, #comment!, #declare!, #initialize, #instruct!, #target!

Methods inherited from XmlBase

#<<, #explicit_nil_handling?, #initialize, #method_missing, #nil?, #tag!

Methods inherited from BlankSlate

find_hidden_method, hide, reveal

Constructor Details

This class inherits a constructor from Builder::XmlMarkup

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Builder::XmlBase

Instance Method Details

#_end_tag(sym) ⇒ Object



59
60
61
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb', line 59

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

#_start_tag(sym, attrs, end_too = false) ⇒ Object



54
55
56
57
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb', line 54

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

#text!(text) ⇒ Object



50
51
52
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/builder-3.2.4/lib/builder/xmlevents.rb', line 50

def text!(text)
  @target.text(text)
end