Class: SAXMachine::SAXConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig
show all
- Defined in:
- lib/lazy-sax-machine/sax_config.rb,
lib/lazy-sax-machine/sax_element_config.rb,
lib/lazy-sax-machine/sax_attribute_config.rb,
lib/lazy-sax-machine/sax_collection_config.rb,
lib/lazy-sax-machine/sax_element_value_config.rb
Defined Under Namespace
Classes: AttributeConfig, CollectionConfig, ElementConfig, ElementValueConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SAXConfig.
10
11
12
13
14
15
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 10
def initialize
@top_level_elements = {}
@top_level_attributes = []
@top_level_element_value = []
@collection_elements = {}
end
|
Instance Attribute Details
#collection_elements ⇒ Object
Returns the value of attribute collection_elements.
8
9
10
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 8
def collection_elements
@collection_elements
end
|
#top_level_attributes ⇒ Object
Returns the value of attribute top_level_attributes.
8
9
10
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 8
def top_level_attributes
@top_level_attributes
end
|
#top_level_element_value ⇒ Object
Returns the value of attribute top_level_element_value.
8
9
10
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 8
def top_level_element_value
@top_level_element_value
end
|
#top_level_elements ⇒ Object
Returns the value of attribute top_level_elements.
8
9
10
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 8
def top_level_elements
@top_level_elements
end
|
Instance Method Details
#add_collection_element(name, options) ⇒ Object
39
40
41
42
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 39
def add_collection_element(name, options)
@collection_elements[name.to_s] = [] unless @collection_elements[name.to_s]
@collection_elements[name.to_s] << CollectionConfig.new(name, options)
end
|
#add_top_level_attribute(name, options) ⇒ Object
31
32
33
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 31
def add_top_level_attribute(name, options)
@top_level_attributes << AttributeConfig.new(options.delete(:name), options)
end
|
#add_top_level_element(name, options) ⇒ Object
26
27
28
29
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 26
def add_top_level_element(name, options)
@top_level_elements[name.to_s] = [] unless @top_level_elements[name.to_s]
@top_level_elements[name.to_s] << ElementConfig.new(name, options)
end
|
#add_top_level_element_value(name, options) ⇒ Object
35
36
37
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 35
def add_top_level_element_value(name, options)
@top_level_element_value << ElementValueConfig.new(options.delete(:name), options)
end
|
#attribute_configs_for_element(attrs) ⇒ Object
49
50
51
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 49
def attribute_configs_for_element(attrs)
@top_level_attributes.select { |aa| aa.attrs_match?(attrs) }
end
|
#collection_config(name, attrs) ⇒ Object
44
45
46
47
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 44
def collection_config(name, attrs)
ces = @collection_elements[name.to_s]
ces && ces.detect { |cc| cc.attrs_match?(attrs) }
end
|
#columns ⇒ Object
17
18
19
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 17
def columns
@top_level_elements.map {|name, ecs| ecs }.flatten
end
|
#element_config_for_tag(name, attrs) ⇒ Object
62
63
64
65
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 62
def element_config_for_tag(name, attrs)
tes = @top_level_elements[name.to_s]
tes && tes.detect { |ec| ec.attrs_match?(attrs) }
end
|
#element_configs_for_attribute(name, attrs) ⇒ Object
57
58
59
60
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 57
def element_configs_for_attribute(name, attrs)
tes = @top_level_elements[name.to_s]
tes && tes.select { |ec| ec.has_value_and_attrs_match?(attrs) } || []
end
|
#element_values_for_element ⇒ Object
53
54
55
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 53
def element_values_for_element
@top_level_element_value
end
|
#initialize_copy(sax_config) ⇒ Object
21
22
23
24
|
# File 'lib/lazy-sax-machine/sax_config.rb', line 21
def initialize_copy(sax_config)
@top_level_elements = sax_config.top_level_elements.clone
@collection_elements = sax_config.collection_elements.clone
end
|