Parent

Methods

Class Index [+]

Quicksearch

Mechanize::Page::Link

This class encapsulates links. It contains the text and the URI for ‘a’ tags parsed out of an HTML page. If the link contains an image, the alt text will be used for that image.

For example, the text for the following links with both be ‘Hello World’:

Hello">rubyforge.org">Hello World rubyforge.org"> src=“test.jpg“ alt=“Hello World”>

Attributes

node[R]
href[R]
text[R]
attributes[R]
page[R]

Public Class Methods

new(node, mech, page) click to toggle source
    # File lib/mechanize/page/link.rb, line 20
20:       def initialize(node, mech, page)
21:         @node = node
22:         @href = node['href']
23:         @text = node.inner_text
24:         @page = page
25:         @mech = mech
26:         @attributes = node
27: 
28:         # If there is no text, try to find an image and use it's alt text
29:         if (@text.nil? || @text.length == 0) && node.search('img').length > 0
30:           @text = ''
31:           node.search('img').each do |e|
32:             @text << ( e['alt'] || '')
33:           end
34:         end
35: 
36:       end

Public Instance Methods

click() click to toggle source

Click on this link

    # File lib/mechanize/page/link.rb, line 43
43:       def click
44:         @mech.click self
45:       end
uri() click to toggle source
    # File lib/mechanize/page/link.rb, line 38
38:       def uri
39:         @href && URI.parse(URI.encode(@href))
40:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.