Module: Mechanize::ElementMatcher

### Home Classes Methods

### In Files

- lib/mechanize/element_matcher.rb

### Methods

- #elements_with

### 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::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::ElementMatcher

### Public Instance Methods

elements_with(singular, plural = "#{singular}s") click to toggle source

    # File lib/mechanize/element_matcher.rb, line 3
    def elements_with singular, plural = "#{singular}s"
      class_eval       def #{plural}_with criteria = {}        criteria = if String === criteria then                     {:name => criteria}                   else                     Hash[criteria.map do |k, v|                            k = :dom_id if k.to_sym == :id                            k = :dom_class if k.to_sym == :class                            [k, v]                          end]                   end        f = select_#{plural}(criteria.delete(:search)).find_all do |thing|          criteria.all? do |k,v|            v === thing.send(k)          end        end        yield f if block_given?        f      end      def #{singular}_with criteria = {}        f = #{plural}_with(criteria).first        yield f if block_given?        f      end      def select_#{plural} selector        if selector.nil? then          #{plural}        else          nodes = search(selector)          #{plural}.find_all do |element|            nodes.include?(element.node)          end        end      end      alias :#{singular} :#{singular}_with
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.