Class | Mechanize::Form::Option |
In: |
lib/mechanize/form/option.rb
|
Parent: | Object |
This class contains option 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. For example, select the first option in a list:
select_list.first.tick
value | -> | to_s |
selected | -> | selected? |
select_list | [R] | |
selected | [R] | |
text | [R] | |
value | [R] |
# File lib/mechanize/form/option.rb, line 14 14: def initialize(node, select_list) 15: @text = node.inner_text 16: @value = Util.html_unescape(node['value'] || node.inner_text) 17: @selected = node.has_attribute? 'selected' 18: @select_list = select_list # The select list this option belongs to 19: end
Toggle the selection value of this option
# File lib/mechanize/form/option.rb, line 36 36: def click 37: unselect_peers 38: @selected = !@selected 39: end
Select this option
# File lib/mechanize/form/option.rb, line 22 22: def select 23: unselect_peers 24: @selected = true 25: end
Unselect this option
# File lib/mechanize/form/option.rb, line 28 28: def unselect 29: @selected = false 30: end