Class: SAXMachine::SAXConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig
show all
- Defined in:
- lib/sax-machine/sax_config.rb,
lib/sax-machine/sax_element_config.rb,
lib/sax-machine/sax_collection_config.rb
Defined Under Namespace
Classes: CollectionConfig, ElementConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SAXConfig.
8
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 8
def initialize
@top_level_elements = []
@collection_elements = []
end
|
Instance Attribute Details
#collection_elements ⇒ Object
Returns the value of attribute collection_elements.
6
7
8
|
# File 'lib/sax-machine/sax_config.rb', line 6
def collection_elements
@collection_elements
end
|
#top_level_elements ⇒ Object
Returns the value of attribute top_level_elements.
6
7
8
|
# File 'lib/sax-machine/sax_config.rb', line 6
def top_level_elements
@top_level_elements
end
|
Instance Method Details
#add_collection_element(name, options) ⇒ Object
17
18
19
|
# File 'lib/sax-machine/sax_config.rb', line 17
def add_collection_element(name, options)
@collection_elements << CollectionConfig.new(name, options)
end
|
#add_top_level_element(name, options) ⇒ Object
13
14
15
|
# File 'lib/sax-machine/sax_config.rb', line 13
def add_top_level_element(name, options)
@top_level_elements << ElementConfig.new(name, options)
end
|
#collection_config(name) ⇒ Object
21
22
23
|
# File 'lib/sax-machine/sax_config.rb', line 21
def collection_config(name)
@collection_elements.detect { |ce| ce.name.to_s == name.to_s }
end
|
#element_config_for_tag(name, attrs) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/sax-machine/sax_config.rb', line 32
def element_config_for_tag(name, attrs)
@top_level_elements.detect do |element_config|
element_config.name == name &&
element_config.attrs_match?(attrs)
end
end
|
#element_configs_for_attribute(name, attrs) ⇒ Object
25
26
27
28
29
30
|
# File 'lib/sax-machine/sax_config.rb', line 25
def element_configs_for_attribute(name, attrs)
@top_level_elements.select do |element_config|
element_config.name == name &&
element_config.has_value_and_attrs_match?(attrs)
end
end
|