| Class | WWW::Mechanize::Form::Option |
| In: |
lib/www/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/www/mechanize/form/option.rb, line 15
15: def initialize(node, select_list)
16: @text = node.inner_text
17: @value = Mechanize.html_unescape(node['value'] || node.inner_text)
18: @selected = node.has_attribute? 'selected'
19: @select_list = select_list # The select list this option belongs to
20: end
Toggle the selection value of this option
# File lib/www/mechanize/form/option.rb, line 37
37: def click
38: unselect_peers
39: @selected = !@selected
40: end
Select this option
# File lib/www/mechanize/form/option.rb, line 23
23: def select
24: unselect_peers
25: @selected = true
26: end
Unselect this option
# File lib/www/mechanize/form/option.rb, line 29
29: def unselect
30: @selected = false
31: end