Sha256: 60b05c57f7e73941d5f1337e7953b3126b2788fe7e1951dad822d2d7c697fd3f

Contents?: true

Size: 534 Bytes

Versions: 5

Compression:

Stored size: 534 Bytes

Contents

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

require_relative 'yasuri_node'

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yasuri-1.9.11 lib/yasuri/yasuri_struct_node.rb
yasuri-2.0.11 lib/yasuri/yasuri_struct_node.rb
yasuri-0.0.11 lib/yasuri/yasuri_struct_node.rb
yasuri-0.0.10 lib/yasuri/yasuri_struct_node.rb
yasuri-0.0.9 lib/yasuri/yasuri_struct_node.rb