Sha256: 790e31686f804fcc3d308f2111cffb991b25b999a6d0ec8508df990717f36de4

Contents?: true

Size: 723 Bytes

Versions: 4

Compression:

Stored size: 723 Bytes

Contents

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

require_relative 'yasuri_node'

module Yasuri
  class LinksNode
    include Node
    def inject(agent, page, opt = {}, element = page)
      retry_count = opt[:retry_count] || 5

      links = element.search(@xpath) || [] # links expected
      links.map do |link|
        link_button = Mechanize::Page::Link.new(link, agent, page)
        child_page = Yasuri.with_retry(retry_count) { link_button.click }

        child_results_kv = @children.map do |child_node|
          child_name = Yasuri.NodeName(child_node.name, opt)
          [child_name, child_node.inject(agent, child_page, opt)]
        end

        Hash[child_results_kv]
      end # each named child node
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yasuri-3.0.0 lib/yasuri/yasuri_links_node.rb
yasuri-2.0.13 lib/yasuri/yasuri_links_node.rb
yasuri-2.0.12 lib/yasuri/yasuri_links_node.rb
yasuri-1.9.12 lib/yasuri/yasuri_links_node.rb