module SAXMachine
Constants
- VERSION
Public Class Methods
configure(clazz) { |extended_clazz| ... }
click to toggle source
# File lib/sax-machine/sax_configure.rb, line 2 def self.configure(clazz) extended_clazz = Class.new(clazz) extended_clazz.send(:include, SAXMachine) # override create_attr to create attributes on the original class 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()
click to toggle source
# File lib/sax-machine.rb, line 7 def self.handler @@handler ||= nil end
handler=(handler)
click to toggle source
# 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)
click to toggle source
# File lib/sax-machine/sax_document.rb, line 2 def self.included(base) base.send(:include, InstanceMethods) base.extend(ClassMethods) end
Public Instance Methods
parse(xml_input, on_error = nil, on_warning = nil)
click to toggle source
# 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