Class: Mechanize::History

### Home Classes Methods

### In Files

- lib/mechanize/history.rb

### Parent

Array

### Methods

- ::new
- #<<
- #clear
- #initialize_copy
- #pop
- #push
- #shift
- #visited?
- #visited_page

### Files

- EXAMPLES.rdoc
- GUIDE.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Mechanize
- Mechanize::ChunkedTerminationError
- Mechanize::ContentTypeError
- Mechanize::Cookie
- Mechanize::CookieCMethods
- Mechanize::CookieDeprecated
- Mechanize::CookieIMethods
- Mechanize::CookieJar
- Mechanize::CookieJarIMethods
- Mechanize::DirectorySaver
- Mechanize::Download
- Mechanize::ElementMatcher
- Mechanize::ElementNotFoundError
- Mechanize::Error
- Mechanize::File
- Mechanize::FileConnection
- Mechanize::FileRequest
- Mechanize::FileResponse
- Mechanize::FileSaver
- Mechanize::Form
- Mechanize::Form::Button
- Mechanize::Form::CheckBox
- Mechanize::Form::Field
- Mechanize::Form::FileUpload
- Mechanize::Form::Hidden
- Mechanize::Form::ImageButton
- Mechanize::Form::Keygen
- Mechanize::Form::MultiSelectList
- Mechanize::Form::Option
- Mechanize::Form::RadioButton
- Mechanize::Form::Reset
- Mechanize::Form::SelectList
- Mechanize::Form::Submit
- Mechanize::Form::Text
- Mechanize::Form::Textarea
- Mechanize::HTTP
- Mechanize::HTTP::Agent
- Mechanize::HTTP::AuthChallenge
- Mechanize::HTTP::AuthRealm
- Mechanize::HTTP::AuthStore
- Mechanize::HTTP::ContentDispositionParser
- Mechanize::HTTP::WWWAuthenticateParser
- Mechanize::Headers
- Mechanize::History
- Mechanize::Image
- Mechanize::Page
- Mechanize::Page::Base
- Mechanize::Page::Frame
- Mechanize::Page::Image
- Mechanize::Page::Label
- Mechanize::Page::Link
- Mechanize::Page::MetaRefresh
- Mechanize::Parser
- Mechanize::PluggableParser
- Mechanize::Prependable
- Mechanize::RedirectLimitReachedError
- Mechanize::RedirectNotGetOrHeadError
- Mechanize::ResponseCodeError
- Mechanize::ResponseReadError
- Mechanize::RobotsDisallowedError
- Mechanize::TestCase
- Mechanize::UnauthorizedError
- Mechanize::UnsupportedSchemeError
- Mechanize::Util
- Mechanize::XmlFile
- HTTP
- HTTP::CookieJar

No matching classes.

# 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

<<(page, uri = nil) click to toggle source
Alias for: push
clear() click to toggle source

    # File lib/mechanize/history.rb, line 50
    def clear
      @history_index.clear
      super
    end

initialize_copy(orig) click to toggle source

    # 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

    # 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

    # 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

    # 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
visited_page(uri) click to toggle source
Alias for: visited?

[Validate]

Generated with the Darkfish Rdoc Generator 2.