Sha256: 67752797bade6becbd1220dd8855456d8476f0b337815212d21374b58931c19a
Contents?: true
Size: 675 Bytes
Versions: 7
Compression:
Stored size: 675 Bytes
Contents
module Hexp module Nokogiri # Read Nokogiri, turning it into Hexp # class Reader # Take a Nokogiri root node and convert it to Hexp # # @param node [Nokogiri::XML::Element] # @return [Hexp::Node] # @api public # def call(node) return node.text if node.text? || node.cdata? unless node.attributes.empty? attrs = node.attributes.map do |key, value| [key.to_sym, value.value] end attrs = Hash[attrs] end recurse = ->(next_node) { call(next_node) } H[node.name.to_sym, attrs || {}, node.children.map(&recurse)] end end end end
Version data entries
7 entries across 7 versions & 1 rubygems