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 7
def initialize(max_size = nil)
  @max_size       = max_size
  @history_index  = {}
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
def clear
  @history_index.clear
  super
end
initialize_copy(orig) click to toggle source
# File lib/mechanize/history.rb, line 12
def initialize_copy(orig)
  super
  @history_index = orig.instance_variable_get(:@history_index).dup
end
pop() click to toggle source
# File lib/mechanize/history.rb, line 51
def pop
  return nil if length == 0
  page = super
  remove_from_index(page)
  page
end
push(page, uri = nil) click to toggle source
# File lib/mechanize/history.rb, line 17
def push(page, uri = nil)
  super(page)
  @history_index[(uri ? uri : page.uri).to_s] = page
  if @max_size && self.length > @max_size
    while self.length > @max_size
      self.shift
    end
  end
  self
end
Also aliased as: <<
shift() click to toggle source
# File lib/mechanize/history.rb, line 42
def shift
  return nil if length == 0
  page    = self[0]
  self[0] = nil
  super
  remove_from_index(page)
  page
end
visited?(url) click to toggle source
# File lib/mechanize/history.rb, line 29
def visited?(url)
  ! visited_page(url).nil?
end
visited_page(url) click to toggle source
# File lib/mechanize/history.rb, line 33
def visited_page(url)
  @history_index[(url.respond_to?(:uri) ? url.uri : url).to_s]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.