Class: SAXMachine::SAXConfig::CollectionConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/sax-machine/sax_collection_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options) ⇒ CollectionConfig

Returns a new instance of CollectionConfig.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sax-machine/sax_collection_config.rb', line 8

def initialize(name, options)
  @name   = name.to_s
  @class  = options[:class]
  @as     = options[:as].to_s
  @xmlns  = case options[:xmlns]
            when Array then options[:xmlns]
            when String then [options[:xmlns]]
            else nil
            end
  @default_xmlns = options[:default_xmlns]
  if @default_xmlns && @xmlns && !@xmlns.include?(EMPTY_STRING)
    @xmlns << EMPTY_STRING
  end
  @record_events = options[:events]
end

Instance Attribute Details

#default_xmlnsObject (readonly)

Returns the value of attribute default_xmlns.



6
7
8
# File 'lib/sax-machine/sax_collection_config.rb', line 6

def default_xmlns
  @default_xmlns
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/sax-machine/sax_collection_config.rb', line 5

def name
  @name
end

Instance Method Details

#accessorObject



36
37
38
# File 'lib/sax-machine/sax_collection_config.rb', line 36

def accessor
  as
end

#handler(nsstack) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sax-machine/sax_collection_config.rb', line 24

def handler(nsstack)
  if @default_xmlns && (nsstack.nil? || nsstack[EMPTY_STRING] == EMPTY_STRING)
    nsstack = NSStack.new(nsstack, nsstack)
    nsstack[EMPTY_STRING] = @default_xmlns
  end
  unless @record_events
    SAXHandler.new(@class.new, nsstack)
  else
    SAXEventRecorder.new(nsstack)
  end
end

#xmlns_match?(ns) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/sax-machine/sax_collection_config.rb', line 40

def xmlns_match?(ns)
  @xmlns.nil? || @xmlns.include?(ns)
end