class 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 def initialize(max_size = nil) @max_size = max_size @history_index = {} end
Public Instance Methods
clear()
click to toggle source
Calls superclass method
# File lib/mechanize/history.rb, line 50 def clear @history_index.clear super end
initialize_copy(orig)
click to toggle source
Calls superclass method
# File lib/mechanize/history.rb, line 13 def initialize_copy(orig) super @history_index = orig.instance_variable_get(:@history_index).dup end
pop()
click to toggle source
Calls superclass method
# File lib/mechanize/history.rb, line 66 def pop return nil if length == 0 page = super remove_from_index(page) page end
push(page, uri = nil)
click to toggle source
Calls superclass method
# File lib/mechanize/history.rb, line 24 def push(page, uri = nil) super page index = uri ? uri : page.uri @history_index[index.to_s] = page shift while length > @max_size if @max_size self end
Also aliased as: <<
shift()
click to toggle source
Calls superclass method
# File lib/mechanize/history.rb, line 55 def shift return nil if length == 0 page = self[0] self[0] = nil super remove_from_index(page) page end
visited?(uri)
click to toggle source
# File lib/mechanize/history.rb, line 37 def visited? uri page = @history_index[uri.to_s] return page if page # HACK uri = uri.dup uri.path = '/' if uri.path.empty? @history_index[uri.to_s] end
Also aliased as: visited_page