Class: Importer::Parser::Xml
- Inherits:
-
Base
- Object
- Base
- Importer::Parser::Xml
show all
- Defined in:
- lib/importer/parser/xml.rb
Overview
XML parser Uses crack/xml lib to parse the XML files.
Instance Attribute Summary
Attributes inherited from Base
#data
Instance Method Summary
collapse
Methods inherited from Base
#initialize, run
Instance Method Details
#run ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/importer/parser/xml.rb', line 8
def run
@data = []
file = File.new(@file)
data = Crack::XML.parse(file)
root = data.shift[1]
if root
objects = root.shift[1]
@data = objects.is_a?(Hash) ? [objects] : objects
end
@data
end
|