Sha256: de3c997a19a48d610b2f0ea22395f5700a6c6051a69c2cba851451ee112107a6
Contents?: true
Size: 767 Bytes
Versions: 2
Compression:
Stored size: 767 Bytes
Contents
module Yasuri class MapNode include Node attr_reader :name, :children def initialize(name, children, **opt) @name = name @children = children @opt = opt end def inject(agent, page, opt = {}, _element = page) child_results_kv = @children.map do |node| [node.name, node.inject(agent, page, opt)] end Hash[child_results_kv] end def to_h node_hash = {} self.opts.each { |k, v| node_hash[k] = v unless v.nil? } children.each do |child| child_node_name = "#{child.node_type_str}_#{child.name}" node_hash[child_node_name] = child.to_h end node_hash end def opts {} end def node_type_str "map".freeze end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yasuri-3.3.2 | lib/yasuri/yasuri_map_node.rb |
yasuri-3.3.1 | lib/yasuri/yasuri_map_node.rb |