Class: Mechanize::Form::Option

### Home Classes Methods

### In Files

- lib/mechanize/form/option.rb

### Parent

Object

### Methods

- ::new
- #click
- #select
- #tick
- #unselect
- #untick

### 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::Form::Option

This class contains an option found within SelectList. A SelectList can have many Option classes associated with it. An option can be selected by calling Option#tick, or Option#click.

To select the first option in a list:

    select_list.first.tick

### Attributes

select_list[R]
selected[R]
selected?[R]
text[R]
to_s[R]
value[R]

### Public Class Methods

new(node, select_list) click to toggle source

    # File lib/mechanize/form/option.rb, line 16
    def initialize(node, select_list)
      @text     = node.inner_text
      @value    = Mechanize::Util.html_unescape(node['value'] || node.inner_text)
      @selected = node.has_attribute? 'selected'
      @select_list = select_list # The select list this option belongs to
    end

### Public Instance Methods

click() click to toggle source

Toggle the selection value of this option

    # File lib/mechanize/form/option.rb, line 38
    def click
      unselect_peers
      @selected = !@selected
    end

select() click to toggle source

Select this option

    # File lib/mechanize/form/option.rb, line 24
    def select
      unselect_peers
      @selected = true
    end

Also aliased as: tick
tick() click to toggle source
Alias for: select
unselect() click to toggle source

Unselect this option

    # File lib/mechanize/form/option.rb, line 30
    def unselect
      @selected = false
    end

Also aliased as: untick
untick() click to toggle source
Alias for: unselect

[Validate]

Generated with the Darkfish Rdoc Generator 2.