Class: AbstractXMLInstantiator::Visitor
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- AbstractXMLInstantiator::Visitor
- Defined in:
- lib/rgen/instantiator/abstract_xml_instantiator.rb
Instance Method Summary collapse
- #characters(str) ⇒ Object
- #controlGC ⇒ Object
- #end_element_namespace(tag, prefix, uri) ⇒ Object
-
#initialize(inst, gcSuspendCount) ⇒ Visitor
constructor
A new instance of Visitor.
- #start_element_namespace(tag, attributes, prefix, uri, ns) ⇒ Object
Constructor Details
#initialize(inst, gcSuspendCount) ⇒ Visitor
Returns a new instance of Visitor.
7 8 9 10 11 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 7 def initialize(inst, gcSuspendCount) @instantiator = inst @gcSuspendCount = gcSuspendCount @namespaces = {} end |
Instance Method Details
#characters(str) ⇒ Object
25 26 27 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 25 def characters(str) @instantiator.text(str) end |
#controlGC ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 29 def controlGC return unless @gcSuspendCount > 0 @gcCounter ||= 0 @gcCounter += 1 if @gcCounter == @gcSuspendCount @gcCounter = 0 GC.enable ObjectSpace.garbage_collect GC.disable end end |
#end_element_namespace(tag, prefix, uri) ⇒ Object
21 22 23 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 21 def end_element_namespace(tag, prefix, uri) @instantiator.end_tag(prefix, tag) end |
#start_element_namespace(tag, attributes, prefix, uri, ns) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 13 def start_element_namespace(tag, attributes, prefix, uri, ns) controlGC ns.each{|n| @namespaces[n[0]] = n[1]} attrs = attributes.collect{|a| [a.prefix ? a.prefix+":"+a.localname : a.localname, a.value]} @instantiator.start_tag(prefix, tag, @namespaces, Hash[*(attrs.flatten)]) attrs.each { |pair| @instantiator.set_attribute(pair[0], pair[1]) } end |