Parent

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

value[R]
selected[R]
text[R]
select_list[R]

Public Class Methods

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

Public Instance Methods

click() click to toggle source

Toggle the selection value of this option

    # File lib/mechanize/form/option.rb, line 38
38:   def click
39:     unselect_peers
40:     @selected = !@selected
41:   end
select() click to toggle source

Select this option

    # File lib/mechanize/form/option.rb, line 24
24:   def select
25:     unselect_peers
26:     @selected = true
27:   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
30:   def unselect
31:     @selected = false
32:   end
Also aliased as: untick
untick() click to toggle source
Alias for: unselect

Private Instance Methods

unselect_peers() click to toggle source
    # File lib/mechanize/form/option.rb, line 44
44:   def unselect_peers
45:     return unless Mechanize::Form::SelectList === @select_list
46: 
47:     @select_list.select_none
48:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.