Class: AbstractXMLInstantiator::XMLScanVisitor
- Inherits:
-
Object
- Object
- AbstractXMLInstantiator::XMLScanVisitor
- Includes:
- XMLScan::NSVisitor
- Defined in:
- lib/rgen/instantiator/abstract_xml_instantiator.rb
Instance Method Summary collapse
- #controlGC ⇒ Object
-
#initialize(inst, gcSuspendCount) ⇒ XMLScanVisitor
constructor
A new instance of XMLScanVisitor.
- #on_attr_value(str) ⇒ Object
- #on_attribute_ns(qname, prefix, localpart) ⇒ Object
- #on_chardata(str) ⇒ Object
- #on_etag(qname) ⇒ Object
- #on_stag_end_empty_ns(qname, namespaces) ⇒ Object
- #on_stag_end_ns(qname, namespaces) ⇒ Object
- #split_qname(qname) ⇒ Object
Constructor Details
#initialize(inst, gcSuspendCount) ⇒ XMLScanVisitor
Returns a new instance of XMLScanVisitor.
10 11 12 13 14 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 10 def initialize(inst, gcSuspendCount) @current_attributes = {} @instantiator = inst @gcSuspendCount = gcSuspendCount end |
Instance Method Details
#controlGC ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 59 def controlGC return unless @gcSuspendCount > 0 @gcCounter ||= 0 @gcCounter += 1 if @gcCounter == @gcSuspendCount @gcCounter = 0 GC.enable ObjectSpace.garbage_collect GC.disable end end |
#on_attr_value(str) ⇒ Object
20 21 22 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 20 def on_attr_value(str) @current_attributes[@current_attr_name] = str end |
#on_attribute_ns(qname, prefix, localpart) ⇒ Object
16 17 18 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 16 def on_attribute_ns(qname, prefix, localpart) @current_attr_name = qname end |
#on_chardata(str) ⇒ Object
55 56 57 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 55 def on_chardata(str) @instantiator.text(str) end |
#on_etag(qname) ⇒ Object
50 51 52 53 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 50 def on_etag(qname) prefix, tag = split_qname(qname) @instantiator.end_tag(prefix, tag) end |
#on_stag_end_empty_ns(qname, namespaces) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 41 def on_stag_end_empty_ns(qname, namespaces) controlGC prefix, tag = split_qname(qname) @instantiator.start_tag(prefix, tag, namespaces, @current_attributes) @current_attributes.each_pair { |k,v| @instantiator.set_attribute(k, v) } @current_attributes = {} @instantiator.end_tag(prefix, tag) end |
#on_stag_end_ns(qname, namespaces) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 33 def on_stag_end_ns(qname, namespaces) controlGC prefix, tag = split_qname(qname) @instantiator.start_tag(prefix, tag, namespaces, @current_attributes) @current_attributes.each_pair { |k,v| @instantiator.set_attribute(k, v) } @current_attributes = {} end |
#split_qname(qname) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 24 def split_qname(qname) if qname =~ /^([^:]+):([^:]+)$/ prefix, tag = $1, $2 else prefix, tag = nil, qname end return prefix, tag end |