Class: AbstractXMLInstantiator
- Inherits:
-
Object
- Object
- AbstractXMLInstantiator
- Defined in:
- lib/rgen/instantiator/abstract_xml_instantiator.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Visitor
Instance Method Summary collapse
-
#instantiate(str, gcSuspendCount = 0) ⇒ Object
Parses str and calls start_tag, end_tag, set_attribute and text methods of a subclass.
- #text(str) ⇒ Object
Instance Method Details
#instantiate(str, gcSuspendCount = 0) ⇒ Object
Parses str and calls start_tag, end_tag, set_attribute and text methods of a subclass.
If gcSuspendCount is specified, the garbage collector will be disabled for that number of start or end tags. After that period it will clean up and then be disabled again. A value of about 1000 can significantly improve overall performance. The memory usage normally does not increase. Depending on the work done for every xml tag the value might have to be adjusted.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 50 def instantiate(str, gcSuspendCount=0) gcDisabledBefore = GC.disable gcSuspendCount = 0 if gcDisabledBefore begin visitor = Visitor.new(self, gcSuspendCount) parser = Nokogiri::XML::SAX::Parser.new(visitor) parser.parse(str) do |ctx| @parserContext = ctx end ensure GC.enable unless gcDisabledBefore end end |
#text(str) ⇒ Object
64 65 |
# File 'lib/rgen/instantiator/abstract_xml_instantiator.rb', line 64 def text(str) end |