Sha256: 893d2f326afbb94f3cb1cd7e3095a0a69ab79886c60e0f304115ac20968cac2e

Contents?: true

Size: 613 Bytes

Versions: 2

Compression:

Stored size: 613 Bytes

Contents

# Author::    TAC (tac@tac42.net)

require_relative 'yasuri_node'

module Yasuri
  class StructNode
    include Node
    def inject(agent, page, opt = {}, element = page)
      sub_tags = element.search(@xpath)
      tree = sub_tags.map do |sub_tag|
        child_results_kv = @children.map do |child_node|
          child_name = Yasuri.node_name(child_node.name, opt)
          [child_name, child_node.inject(agent, page, opt, sub_tag)]
        end
        Hash[child_results_kv]
      end
      tree.size == 1 ? tree.first : tree
    end # inject

    def node_type_str
      "struct".freeze
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yasuri-3.3.0 lib/yasuri/yasuri_struct_node.rb
yasuri-3.2.0 lib/yasuri/yasuri_struct_node.rb