module XMLScan::ElementProcessor
Constants
- MY_METHODS
- SKIP
Public Class Methods
new(opts={}, mod=nil)
click to toggle source
# File lib/xmlscan/processor.rb 16 def initialize(opts={}, mod=nil) 17 raise "No module" unless mod 18 (MY_METHODS - mod.instance_methods).each do |i| 19 self.class.class_eval %{def #{i}(d, *a) d&&(self << d) end}, __FILE__, __LINE__ 20 end 21 self.class.send :include, mod 22 23 @element = opts[:element] || raise("need an element") 24 @key = opts[:key] || raise("need a key") 25 @extras = (ex = opts[:extras]) ? ex.map(&:to_sym) : [] 26 @tmpl = opts[:substitute] || "{{:key}}" 27 28 @pairs = {} # output name=> [content, context, extra_values] * 1 or more 29 @context = '' # current key(name) of the element (card) 30 @stack = [] # stack of containing context cards 31 @out = [] # current output for name(card) 32 @parser = XMLScan::XMLParser.new(self) 33 self 34 end