Class: Rsxml::Visitor::WriteXmlVisitor
- Inherits:
-
Object
- Object
- Rsxml::Visitor::WriteXmlVisitor
- Defined in:
- lib/rsxml/visitor.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #element(context, name, attrs, ns_decls) ⇒ Object
-
#initialize(xml_builder = nil) ⇒ WriteXmlVisitor
constructor
A new instance of WriteXmlVisitor.
- #text(context, text) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(xml_builder = nil) ⇒ WriteXmlVisitor
Returns a new instance of WriteXmlVisitor.
18 19 20 |
# File 'lib/rsxml/visitor.rb', line 18 def initialize(xml_builder=nil) @xml = xml_builder || Builder::XmlMarkup.new end |
Instance Attribute Details
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
16 17 18 |
# File 'lib/rsxml/visitor.rb', line 16 def xml @xml end |
Instance Method Details
#element(context, name, attrs, ns_decls) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rsxml/visitor.rb', line 22 def element(context, name, attrs, ns_decls) qname = Namespace::compact_qname(context.ns_stack, name) qattrs = Namespace::compact_attr_qnames(context.ns_stack, attrs) ns_attrs = Namespace::namespace_attributes(ns_decls) attrs = qattrs.merge(ns_attrs) xml.__send__(qname, attrs) do yield end end |
#text(context, text) ⇒ Object
33 34 35 |
# File 'lib/rsxml/visitor.rb', line 33 def text(context, text) xml << text end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/rsxml/visitor.rb', line 37 def to_s xml.target! end |