Module: BlocklyInterpreter::DSL
- Defined in:
- lib/blockly_interpreter/dsl.rb
Defined Under Namespace
Classes: BinaryOperationBlockBuilder, BinaryOperationDSLGenerator, BlockBuilder, BlockContext
Class Method Summary collapse
Class Method Details
.build_xml(&block) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/blockly_interpreter/dsl.rb', line 271 def self.build_xml(&block) doc = Nokogiri::XML::Document.new root = Nokogiri::XML::Node.new('xml', doc) root['xmlns'] = 'http://www.w3.org/1999/xhtml' doc.add_child root context = BlockContext.new context.instance_exec(&block) first_block = context.to_xml(doc) root.add_child(first_block) if first_block context.procedure_blocks.each do |proc| Nokogiri::XML::Node.new(proc.tag_name, doc).tap do |node| proc.to_xml(node) root.add_child(node) end end doc.to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION | Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS) end |