| Class | WWW::Mechanize::Form::SelectList |
| In: |
lib/www/mechanize/form/select_list.rb
|
| Parent: | MultiSelectList |
This class represents a select list or drop down box in a Form. Set the value for the list by calling SelectList#value=. SelectList contains a list of Option that were found. After finding the correct option, set the select lists value to the option value:
selectlist.value = selectlist.options.first.value
Options can also be selected by "clicking" or selecting them. See Option
# File lib/www/mechanize/form/select_list.rb, line 11
11: def initialize(name, node)
12: super(name, node)
13: if selected_options.length > 1
14: selected_options.reverse[1..selected_options.length].each do |o|
15: o.unselect
16: end
17: end
18: end
# File lib/www/mechanize/form/select_list.rb, line 39
39: def query_value
40: value ? [[name, value]] : ''
41: end
# File lib/www/mechanize/form/select_list.rb, line 20
20: def value
21: value = super
22: if value.length > 0
23: value.last
24: elsif @options.length > 0
25: @options.first.value
26: else
27: nil
28: end
29: end