module Dhall::XML
Constants
- TYPE
Public Class Methods
from_dhall(expr, doc=Nokogiri::XML::Document.new)
click to toggle source
# File lib/dhall/xml.rb, line 36 def self.from_dhall(expr, doc=Nokogiri::XML::Document.new) return expr.unwrap if expr.is_a?(RubyObjectRaw) TypeChecker.annotate( TypeAnnotation.new(value: expr, type: TYPE) ).value.( TYPE, # dummy element: FunctionProxyRaw.new(->(record) { from_element(record, doc) }), text: FunctionProxyRaw.new(doc.method(:create_text_node)) ).unwrap end
from_element(record, doc=Nokogiri::XML::Document.new)
click to toggle source
# File lib/dhall/xml.rb, line 48 def self.from_element(record, doc=Nokogiri::XML::Document.new) doc.create_element( record.fetch(:name).to_s, Coder.new.decode(record.fetch(:attributes)) ) do |el| el.add_child(Nokogiri::XML::NodeSet.new( doc, record.fetch(:content).to_a.map { |xml| from_dhall(xml, doc) } )) end end