16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/xmlscan/processor.rb', line 16
def initialize(opts={}, mod=nil)
raise "No module" unless mod
(MY_METHODS - mod.instance_methods).each do |i|
self.class.class_eval %{def #{i}(d, *a) d&&(self << d) end}, __FILE__, __LINE__
end
self.class.send :include, mod
@element = opts[:element] || raise("need an element")
@key = opts[:key] || raise("need a key")
= (ex = opts[:extras]) ? ex.map(&:to_sym) : []
@tmpl = opts[:substitute] || "{{:key}}"
@pairs = {}
@context = ''
@stack = []
@out = []
@parser = XMLScan::XMLParser.new(self)
self
end
|