Class: Innards::Parsers::GetMetadataParser
- Inherits:
-
ParserBase
- Object
- Ox::Sax
- ParserBase
- Innards::Parsers::GetMetadataParser
show all
- Defined in:
- lib/innards/parsers/get_metadata_parser.rb
Overview
SAX Parser for RETS Metadata
Constant Summary
collapse
- METADATA_SECTIONS =
{
"METADATA-RESOURCE" => :resources,
"METADATA-CLASS" => :classes,
"METADATA-TABLE" => :tables,
"METADATA-OBJECT" => :objects,
"METADATA-SEARCH_HELP" => :search_help,
"METADATA-EDITMASK" => :edit_masks,
"METADATA-LOOKUP" => :lookups,
"METADATA-LOOKUP_TYPE" => :lookup_types
}
Instance Attribute Summary
Attributes inherited from ParserBase
#metadata, #rets_response
Instance Method Summary
collapse
Methods inherited from ParserBase
#data_merger, #data_splitter, #element_tracker_switch, #response_code, #split_multiline_key_value_pairs, #switch_active?, #valid_rets_response_received?
Constructor Details
Returns a new instance of GetMetadataParser.
19
20
21
22
|
# File 'lib/innards/parsers/get_metadata_parser.rb', line 19
def initialize
super()
@current_builder = {}
end
|
Instance Method Details
#attr(name, value) ⇒ Object
35
36
37
38
39
40
41
42
|
# File 'lib/innards/parsers/get_metadata_parser.rb', line 35
def attr(name, value)
super
METADATA_SECTIONS.each_key do |section|
if switch_active?(:"#{section}")
@current_builder[name.to_sym] = value
end
end
end
|
#end_element(name) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/innards/parsers/get_metadata_parser.rb', line 28
def end_element(name)
super
if METADATA_SECTIONS.has_key?(name.to_s)
@current_builder = {}
end
end
|
#start_element(name) ⇒ Object
24
25
26
|
# File 'lib/innards/parsers/get_metadata_parser.rb', line 24
def start_element(name)
super
end
|
#text(value) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/innards/parsers/get_metadata_parser.rb', line 44
def text(value)
super
if switch_active?(:COLUMNS)
@current_builder[:columns] = data_splitter(value)
end
METADATA_SECTIONS.each_pair do |section, symbol|
if switch_active?(:"#{section}") and switch_active?(:DATA)
parsed_data = data_merger(@current_builder[:columns], data_splitter(value))
filtered = @current_builder.reject{ |key| key == :columns }
@metadata[symbol] = [] unless @metadata.has_key?(symbol)
@metadata[symbol].push parsed_data.merge(filtered)
end
end
end
|