Class: Hash
- Inherits:
-
Object
- Object
- Hash
- Defined in:
- lib/ebngen/adapter/iar/ewp.rb
Overview
require ‘FileUtils’
Instance Method Summary collapse
- #to_xml(doc) ⇒ Object
-
#to_xml!(doc) ⇒ Object
end to_xml.
Instance Method Details
#to_xml(doc) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ebngen/adapter/iar/ewp.rb', line 6 def to_xml(doc) return if doc.nil? self.each do |key, value| mynode = Nokogiri::XML::Node.new key, doc doc.add_child mynode value.to_xml(mynode) if value.class == Hash mynode.content = value if value.class == String or value.class == Fixnum end return doc end |
#to_xml!(doc) ⇒ Object
end to_xml
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ebngen/adapter/iar/ewp.rb', line 16 def to_xml!(doc) return if doc.nil? self.each do |key, value| if doc.css("/#{key}").count == 0 mynode = Nokogiri::XML::Node.new key, doc else mynode = doc.css("/#{key}")[0] end doc.add_child mynode value.to_xml(mynode) if value.class == Hash mynode.content = value if value.class == String or value.class == Fixnum end return doc end |