Class: Saxerator::Parser::LatchedAccumulator
- Inherits:
-
Nokogiri::XML::SAX::Document
- Object
- Nokogiri::XML::SAX::Document
- Saxerator::Parser::LatchedAccumulator
- Defined in:
- lib/saxerator/parser/latched_accumulator.rb
Instance Method Summary collapse
- #cdata_block(string) ⇒ Object
- #characters(string) ⇒ Object
- #check_latches_and_passthrough(method, *args) ⇒ Object
- #comment(string) ⇒ Object
- #end_document ⇒ Object
- #end_element(name) ⇒ Object
- #end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object
- #error(string) ⇒ Object
-
#initialize(config, latches, block) ⇒ LatchedAccumulator
constructor
A new instance of LatchedAccumulator.
- #start_document ⇒ Object
- #start_element(name, attrs = []) ⇒ Object
- #start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) ⇒ Object
- #warning(string) ⇒ Object
- #xmldecl(version, encoding, standalone) ⇒ Object
Constructor Details
#initialize(config, latches, block) ⇒ LatchedAccumulator
Returns a new instance of LatchedAccumulator.
4 5 6 7 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 4 def initialize(config, latches, block) @latches = latches @accumulator = Accumulator.new(config, block) end |
Instance Method Details
#cdata_block(string) ⇒ Object
61 62 63 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 61 def cdata_block(string) check_latches_and_passthrough(:cdata_block, string) end |
#characters(string) ⇒ Object
45 46 47 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 45 def characters(string) check_latches_and_passthrough(:characters, string) end |
#check_latches_and_passthrough(method, *args) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 9 def check_latches_and_passthrough(method, *args) @latches.each { |latch| latch.send(method, *args) } if @accumulator.accumulating? || @latches.all? { |latch| latch.open? } @accumulator.send(method, *args) end end |
#comment(string) ⇒ Object
49 50 51 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 49 def comment(string) check_latches_and_passthrough(:comment, string) end |
#end_document ⇒ Object
25 26 27 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 25 def end_document check_latches_and_passthrough(:end_document) end |
#end_element(name) ⇒ Object
33 34 35 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 33 def end_element(name) check_latches_and_passthrough(:end_element, name) end |
#end_element_namespace(name, prefix = nil, uri = nil) ⇒ Object
41 42 43 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 41 def end_element_namespace(name, prefix = nil, uri = nil) check_latches_and_passthrough(:end_element_namespace, name, prefix, uri) end |
#error(string) ⇒ Object
57 58 59 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 57 def error(string) check_latches_and_passthrough(:error, string) end |
#start_document ⇒ Object
21 22 23 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 21 def start_document check_latches_and_passthrough(:start_document) end |
#start_element(name, attrs = []) ⇒ Object
29 30 31 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 29 def start_element(name, attrs = []) check_latches_and_passthrough(:start_element, name, attrs) end |
#start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) ⇒ Object
37 38 39 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 37 def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) check_latches_and_passthrough(:start_element_namespace, name, attrs, prefix, uri, ns) end |
#warning(string) ⇒ Object
53 54 55 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 53 def warning(string) check_latches_and_passthrough(:warning, string) end |
#xmldecl(version, encoding, standalone) ⇒ Object
17 18 19 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 17 def xmldecl(version, encoding, standalone) check_latches_and_passthrough(:xmldecl, version, encoding, standalone) end |