Module: SAXMachine
- Defined in:
- lib/sax-machine.rb,
lib/sax-machine/version.rb,
lib/sax-machine/sax_config.rb,
lib/sax-machine/sax_document.rb,
lib/sax-machine/sax_configure.rb,
lib/sax-machine/config/sax_element.rb,
lib/sax-machine/config/sax_ancestor.rb,
lib/sax-machine/config/sax_attribute.rb,
lib/sax-machine/config/sax_collection.rb,
lib/sax-machine/handlers/sax_ox_handler.rb,
lib/sax-machine/config/sax_element_value.rb,
lib/sax-machine/handlers/sax_oga_handler.rb,
lib/sax-machine/handlers/sax_abstract_handler.rb,
lib/sax-machine/handlers/sax_nokogiri_handler.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, LightWeightSaxMachine, SAXAbstractHandler
Classes: SAXConfig, SAXNokogiriHandler, SAXOgaHandler, SAXOxHandler
Constant Summary
collapse
- VERSION =
"1.3.2"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/sax-machine/sax_configure.rb', line 2
def self.configure(clazz)
extended_clazz = Class.new(clazz)
extended_clazz.send(:include, SAXMachine)
def extended_clazz.create_attr real_name
superclass.send(:attr_reader, real_name) unless superclass.method_defined?(real_name)
superclass.send(:attr_writer, real_name) unless superclass.method_defined?("#{real_name}=")
end
yield(extended_clazz)
clazz.extend LightWeightSaxMachine
clazz.sax_config = extended_clazz.sax_config
(class << clazz;self;end).send(:define_method, :parse) do |xml_input|
extended_clazz.parse(xml_input)
end
end
|
.handler ⇒ Object
7
8
9
|
# File 'lib/sax-machine.rb', line 7
def self.handler
@@handler ||= nil
end
|
.handler=(handler) ⇒ Object
11
12
13
14
15
16
|
# File 'lib/sax-machine.rb', line 11
def self.handler=(handler)
if handler
require "sax-machine/handlers/sax_#{handler}_handler"
@@handler = handler
end
end
|
.included(base) ⇒ Object
2
3
4
5
|
# File 'lib/sax-machine/sax_document.rb', line 2
def self.included(base)
base.send(:include, InstanceMethods)
base.extend(ClassMethods)
end
|
Instance Method Details
#parse(xml_input, on_error = nil, on_warning = nil) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/sax-machine/sax_document.rb', line 7
def parse(xml_input, on_error = nil, on_warning = nil)
handler_klass = SAXMachine.const_get("SAX#{SAXMachine.handler.capitalize}Handler")
handler = handler_klass.new(self, on_error, on_warning)
handler.sax_parse(xml_input)
self
end
|