Parent

Mechanize::History

This class manages history for your mechanize object.

Attributes

max_size[RW]

Public Class Methods

new(max_size = nil) click to toggle source
    # File lib/mechanize/history.rb, line 8
 8:   def initialize(max_size = nil)
 9:     @max_size       = max_size
10:     @history_index  = {}
11:   end

Public Instance Methods

<<(page, uri = nil) click to toggle source
Alias for: push
clear() click to toggle source
    # File lib/mechanize/history.rb, line 50
50:   def clear
51:     @history_index.clear
52:     super
53:   end
initialize_copy(orig) click to toggle source
    # File lib/mechanize/history.rb, line 13
13:   def initialize_copy(orig)
14:     super
15:     @history_index = orig.instance_variable_get(:@history_index).dup
16:   end
pop() click to toggle source
    # File lib/mechanize/history.rb, line 66
66:   def pop
67:     return nil if length == 0
68:     page = super
69:     remove_from_index(page)
70:     page
71:   end
push(page, uri = nil) click to toggle source
    # File lib/mechanize/history.rb, line 24
24:   def push(page, uri = nil)
25:     super page
26: 
27:     index = uri ? uri : page.uri
28:     @history_index[index.to_s] = page
29: 
30:     shift while length > @max_size if @max_size
31: 
32:     self
33:   end
Also aliased as: <<
shift() click to toggle source
    # File lib/mechanize/history.rb, line 55
55:   def shift
56:     return nil if length == 0
57:     page    = self[0]
58:     self[0] = nil
59: 
60:     super
61: 
62:     remove_from_index(page)
63:     page
64:   end
visited?(uri) click to toggle source
    # File lib/mechanize/history.rb, line 37
37:   def visited? uri
38:     page = @history_index[uri.to_s]
39: 
40:     return page if page # HACK
41: 
42:     uri = uri.dup
43:     uri.path = '/' if uri.path.empty?
44: 
45:     @history_index[uri.to_s]
46:   end
Also aliased as: visited_page
visited_page(uri) click to toggle source
Alias for: visited?

Private Instance Methods

remove_from_index(page) click to toggle source
    # File lib/mechanize/history.rb, line 75
75:   def remove_from_index(page)
76:     @history_index.each do |k,v|
77:       @history_index.delete(k) if v == page
78:     end
79:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.