class 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
node[R]
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 17 def initialize(node, select_list) @node = node @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 40 def click unselect_peers @selected = !@selected end
select()
click to toggle source
Select this option
# File lib/mechanize/form/option.rb, line 26 def select unselect_peers @selected = true end
Also aliased as: tick
unselect()
click to toggle source
Unselect this option
# File lib/mechanize/form/option.rb, line 32 def unselect @selected = false end
Also aliased as: untick
Private Instance Methods
unselect_peers()
click to toggle source
# File lib/mechanize/form/option.rb, line 46 def unselect_peers return unless Mechanize::Form::SelectList === @select_list @select_list.select_none end