Module: Saxxy::Callbacks::SAX

Included in:
Libxml, Nokogiri, Ox
Defined in:
lib/saxxy/callbacks/sax.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


10
11
12
13
14
# File 'lib/saxxy/callbacks/sax.rb', line 10

def self.included(base)
  base.extend Forwardable
  base.def_delegators :@event_registry, :activate_events_on, :deactivate_events_on,
    :push_text, :register_event_from_action, :remove_actions!
end

Instance Method Details

#initialize(context) ⇒ Object


16
17
18
19
# File 'lib/saxxy/callbacks/sax.rb', line 16

def initialize(context)
  initialize_state
  @active_pool << context
end

#on_characters(string) ⇒ Object


26
27
28
# File 'lib/saxxy/callbacks/sax.rb', line 26

def on_characters(string)
  push_text(string || "")
end

#on_end_documentObject


35
36
37
38
39
# File 'lib/saxxy/callbacks/sax.rb', line 35

def on_end_document
  @active_pool.clear
  @inactive_pool.clear
  @event_registry.clear
end

#on_end_element(name) ⇒ Object


30
31
32
33
# File 'lib/saxxy/callbacks/sax.rb', line 30

def on_end_element(name)
  deactivate_events_on(name)
  deactivate_contexts_on(name)
end

#on_start_element(name, attrs = {}) ⇒ Object


21
22
23
24
# File 'lib/saxxy/callbacks/sax.rb', line 21

def on_start_element(name, attrs = {})
  register_and_activate_events_on(name, attrs)
  activate_contexts_on(name, attrs)
end