Mechanize::Page::MetaRefresh

This class encapsulates a meta element with a refresh http-equiv. Mechanize treats meta refresh elements just like ‘a’ tags. MetaRefresh objects will contain links, but most likely will have no text.

Constants

CONTENT_REGEXP

Matches the content attribute of a meta refresh element. After the match:

  $1:: delay
  $3:: url
UNSAFE

Regexp of unsafe URI characters that excludes % for Issue #177

Attributes

delay[R]

Time to wait before next refresh

Public Class Methods

from_node(node, page, uri = nil) click to toggle source
    # File lib/mechanize/page/meta_refresh.rb, line 55
55:   def self.from_node node, page, uri = nil
56:     http_equiv = node['http-equiv'] and
57:       /\ARefresh\z/ =~ http_equiv or return
58: 
59:     delay, uri, link_self = parse node['content'], uri
60: 
61:     return unless delay
62: 
63:     new node, page, delay, uri, link_self
64:   end
new(node, page, delay, href, link_self = false) click to toggle source
    # File lib/mechanize/page/meta_refresh.rb, line 66
66:   def initialize node, page, delay, href, link_self = false
67:     super node, page.mech, page
68: 
69:     @delay     = delay.include?(..) ? delay.to_f : delay.to_i
70:     @href      = href
71:     @link_self = link_self
72:   end
parse(content, base_uri = nil) click to toggle source

Parses the delay and url from the content attribute of a meta refresh element.

Returns an array of [delay, url, link_self], where the first two are strings containing the respective parts of the refresh value, and link_self is a boolean value that indicates whether the url part is missing or empty. If base_uri, the URI of the current page is given, the value of url becomes an absolute URI.

    # File lib/mechanize/page/meta_refresh.rb, line 42
42:   def self.parse content, base_uri = nil
43:     m = CONTENT_REGEXP.match(content) or return
44: 
45:     delay, url = m[1], m[3]
46:     url &&= url.empty? ? nil : Mechanize::Util.uri_escape(url, UNSAFE)
47:     link_self = url.nil?
48:     if base_uri
49:       url = url ? base_uri + url : base_uri
50:     end
51: 
52:     return delay, url, link_self
53:   end

Public Instance Methods

noreferrer?() click to toggle source
    # File lib/mechanize/page/meta_refresh.rb, line 74
74:   def noreferrer?
75:     true
76:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.