Class: LibEagle::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/libeagle/libeagle.rb

Class Method Summary collapse

Class Method Details

.initElementClass(name, xml) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/libeagle/libeagle.rb', line 5

def self.initElementClass(name,xml)
  class_name = LibEagle::CLASS_NAMES[name]
  if class_name
    LibEagle::const_get(class_name).new_with_xml(xml)
  else
    raise ElementClassNotFound.new("Element: `#{name}` class wasn't found in the list of the known classes")
  end
end

.parseFile(file) ⇒ Object



14
15
16
17
# File 'lib/libeagle/libeagle.rb', line 14

def self.parseFile(file)
	content = IO.read(file)
	parseXML(content)
end

.parseXML(xml_content) ⇒ Object



19
20
21
22
23
24
# File 'lib/libeagle/libeagle.rb', line 19

def self.parseXML(xml_content)
  xml = Nokogiri::XML(xml_content)
  root = xml.root
  eagle = initElementClass(root.name, root)
  return eagle
end