Parent

Class Index [+]

Quicksearch

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 7
 7:     def initialize(max_size = nil)
 8:       @max_size       = max_size
 9:       @history_index  = {}
10:     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 37
37:     def clear
38:       @history_index.clear
39:       super
40:     end
initialize_copy(orig) click to toggle source
    # File lib/mechanize/history.rb, line 12
12:     def initialize_copy(orig)
13:       super
14:       @history_index = orig.instance_variable_get(:@history_index).dup
15:     end
pop() click to toggle source
    # File lib/mechanize/history.rb, line 51
51:     def pop
52:       return nil if length == 0
53:       page = super
54:       remove_from_index(page)
55:       page
56:     end
push(page, uri = nil) click to toggle source
    # File lib/mechanize/history.rb, line 17
17:     def push(page, uri = nil)
18:       super(page)
19:       @history_index[(uri ? uri : page.uri).to_s] = page
20:       if @max_size && self.length > @max_size
21:         while self.length > @max_size
22:           self.shift
23:         end
24:       end
25:       self
26:     end
Also aliased as: <<
shift() click to toggle source
    # File lib/mechanize/history.rb, line 42
42:     def shift
43:       return nil if length == 0
44:       page    = self[0]
45:       self[0] = nil
46:       super
47:       remove_from_index(page)
48:       page
49:     end
visited?(url) click to toggle source
    # File lib/mechanize/history.rb, line 29
29:     def visited?(url)
30:       ! visited_page(url).nil?
31:     end
visited_page(url) click to toggle source
    # File lib/mechanize/history.rb, line 33
33:     def visited_page(url)
34:       @history_index[(url.respond_to?(:uri) ? url.uri : url).to_s]
35:     end

Private Instance Methods

remove_from_index(page) click to toggle source
    # File lib/mechanize/history.rb, line 59
59:     def remove_from_index(page)
60:       @history_index.each do |k,v|
61:         @history_index.delete(k) if v == page
62:       end
63:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.