Class: SAXMachine::SAXConfig
- Inherits:
-
Object
- Object
- SAXMachine::SAXConfig
show all
- Defined in:
- lib/sax-machine/sax_config.rb,
lib/sax-machine/config/sax_element.rb,
lib/sax-machine/config/sax_ancestor.rb,
lib/sax-machine/config/sax_attribute.rb,
lib/sax-machine/config/sax_collection.rb,
lib/sax-machine/config/sax_element_value.rb
Defined Under Namespace
Classes: AncestorConfig, AttributeConfig, CollectionConfig, ElementConfig, ElementValueConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SAXConfig.
11
12
13
14
15
16
17
18
|
# File 'lib/sax-machine/sax_config.rb', line 11
def initialize
@top_level_elements = Hash.new { |hash, key| hash[key] = [] }
@top_level_attributes = []
@top_level_element_value = []
@collection_elements = Hash.new { |hash, key| hash[key] = [] }
@ancestors = []
end
|
Instance Attribute Details
#ancestors ⇒ Object
Returns the value of attribute ancestors.
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 9
def ancestors
@ancestors
end
|
#collection_elements ⇒ Object
Returns the value of attribute collection_elements.
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 9
def collection_elements
@collection_elements
end
|
#top_level_attributes ⇒ Object
Returns the value of attribute top_level_attributes.
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 9
def top_level_attributes
@top_level_attributes
end
|
#top_level_element_value ⇒ Object
Returns the value of attribute top_level_element_value.
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 9
def top_level_element_value
@top_level_element_value
end
|
#top_level_elements ⇒ Object
Returns the value of attribute top_level_elements.
9
10
11
|
# File 'lib/sax-machine/sax_config.rb', line 9
def top_level_elements
@top_level_elements
end
|
Instance Method Details
#add_ancestor(name, options) ⇒ Object
50
51
52
|
# File 'lib/sax-machine/sax_config.rb', line 50
def add_ancestor(name, options)
@ancestors << AncestorConfig.new(name, options)
end
|
#add_collection_element(name, options) ⇒ Object
46
47
48
|
# File 'lib/sax-machine/sax_config.rb', line 46
def add_collection_element(name, options)
@collection_elements[name.to_s] << CollectionConfig.new(name, options)
end
|
#add_top_level_attribute(name, options) ⇒ Object
38
39
40
|
# File 'lib/sax-machine/sax_config.rb', line 38
def add_top_level_attribute(name, options)
@top_level_attributes << AttributeConfig.new(options.delete(:name), options)
end
|
#add_top_level_element(name, options) ⇒ Object
34
35
36
|
# File 'lib/sax-machine/sax_config.rb', line 34
def add_top_level_element(name, options)
@top_level_elements[name.to_s] << ElementConfig.new(name, options)
end
|
#add_top_level_element_value(name, options) ⇒ Object
42
43
44
|
# File 'lib/sax-machine/sax_config.rb', line 42
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
58
59
60
|
# File 'lib/sax-machine/sax_config.rb', line 58
def attribute_configs_for_element(attrs)
@top_level_attributes.select { |aa| aa.attrs_match?(attrs) }
end
|
#collection_config(name, attrs) ⇒ Object
54
55
56
|
# File 'lib/sax-machine/sax_config.rb', line 54
def collection_config(name, attrs)
@collection_elements[name.to_s].detect { |cc| cc.attrs_match?(attrs) }
end
|
#columns ⇒ Object
20
21
22
|
# File 'lib/sax-machine/sax_config.rb', line 20
def columns
@top_level_elements.map { |_, ecs| ecs }.flatten
end
|
#element_config_for_tag(name, attrs) ⇒ Object
72
73
74
75
76
|
# File 'lib/sax-machine/sax_config.rb', line 72
def element_config_for_tag(name, attrs)
return unless @top_level_elements.has_key?(name.to_s)
@top_level_elements[name.to_s].detect { |ec| ec.attrs_match?(attrs) }
end
|
#element_configs_for_attribute(name, attrs) ⇒ Object
66
67
68
69
70
|
# File 'lib/sax-machine/sax_config.rb', line 66
def element_configs_for_attribute(name, attrs)
return [] unless @top_level_elements.has_key?(name.to_s)
@top_level_elements[name.to_s].select { |ec| ec.has_value_and_attrs_match?(attrs) }
end
|
#element_values_for_element ⇒ Object
62
63
64
|
# File 'lib/sax-machine/sax_config.rb', line 62
def element_values_for_element
@top_level_element_value
end
|
#initialize_copy(sax_config) ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/sax-machine/sax_config.rb', line 24
def initialize_copy(sax_config)
super
@top_level_elements = sax_config.top_level_elements.clone
@top_level_attributes = sax_config.top_level_attributes.clone
@top_level_element_value = sax_config.top_level_element_value.clone
@collection_elements = sax_config.collection_elements.clone
@ancestors = sax_config.ancestors.clone
end
|