Class: Smoke::Transformers::XML
- Inherits:
-
Smoke::Transformer
- Object
- Smoke::Transformer
- Smoke::Transformers::XML
- Defined in:
- lib/smoke/transformers/xml.rb
Class Method Summary collapse
Class Method Details
.generate(tree_name, items) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/smoke/transformers/xml.rb', line 6 def self.generate(tree_name, items) builder = Nokogiri::XML::Builder.new do |xml| xml.items { items.each do |item| xml.item { %w(id type class fork).each{|m| item["#{m}_".to_sym] = item.delete(m.to_sym) } item.each do |k, v| xml.__send__(k, v) end } end } end builder.to_xml end |
.parse(string) ⇒ Object
24 25 26 |
# File 'lib/smoke/transformers/xml.rb', line 24 def self.parse(string) ::Crack::XML.parse(string) end |