Class: Saxerator::Parser::LatchedAccumulator
- Inherits:
-
SaxHandler
- Object
- SaxHandler
- Saxerator::Parser::LatchedAccumulator
- Defined in:
- lib/saxerator/parser/latched_accumulator.rb
Instance Method Summary collapse
- #characters(string) ⇒ Object
- #check_latches_and_passthrough(method, *args) ⇒ Object
- #end_element(name) ⇒ Object
- #ignore_namespaces? ⇒ Boolean
-
#initialize(config, latches, block) ⇒ LatchedAccumulator
constructor
A new instance of LatchedAccumulator.
- #start_element(name, attrs = []) ⇒ Object
Constructor Details
#initialize(config, latches, block) ⇒ LatchedAccumulator
Returns a new instance of LatchedAccumulator.
4 5 6 7 8 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 4 def initialize(config, latches, block) @latches = latches @accumulator = Accumulator.new(config, block) @ignore_namespaces = config.ignore_namespaces? end |
Instance Method Details
#characters(string) ⇒ Object
23 24 25 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 23 def characters(string) check_latches_and_passthrough(:characters, string) end |
#check_latches_and_passthrough(method, *args) ⇒ Object
10 11 12 13 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 10 def check_latches_and_passthrough(method, *args) @latches.each { |latch| latch.send(method, *args) } @accumulator.send(method, *args) if @accumulator.accumulating? || @latches.all?(&:open?) end |
#end_element(name) ⇒ Object
19 20 21 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 19 def end_element(name) check_latches_and_passthrough(:end_element, name) end |
#ignore_namespaces? ⇒ Boolean
27 28 29 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 27 def ignore_namespaces? @ignore_namespaces end |
#start_element(name, attrs = []) ⇒ Object
15 16 17 |
# File 'lib/saxerator/parser/latched_accumulator.rb', line 15 def start_element(name, attrs = []) check_latches_and_passthrough(:start_element, name, attrs) end |