Class WWW::Mechanize::SelectList
In: lib/mechanize/form_elements.rb
Parent: MultiSelectList
Mechanize\n[lib/mechanize.rb\nlib/mechanize/cookie.rb\nlib/mechanize/errors.rb\nlib/mechanize/form.rb\nlib/mechanize/form_elements.rb\nlib/mechanize/history.rb\nlib/mechanize/list.rb\nlib/mechanize/page.rb\nlib/mechanize/page_elements.rb\nlib/mechanize/pluggable_parsers.rb] lib/mechanize.rb WWW dot/m_19_0.png

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

Methods

new   value   value=  

Public Class methods

[Source]

     # File lib/mechanize/form_elements.rb, line 179
179:     def initialize(name, node)
180:       super(name, node)
181:       if selected_options.length > 1
182:         selected_options.reverse[1..selected_options.length].each do |o|
183:           o.unselect
184:         end
185:       end
186:     end

Public Instance methods

[Source]

     # File lib/mechanize/form_elements.rb, line 188
188:     def value
189:       value = super
190:       if value.length > 0
191:         value.last
192:       elsif @options.length > 0
193:         @options.first.value
194:       else
195:         nil
196:       end
197:     end

[Source]

     # File lib/mechanize/form_elements.rb, line 199
199:     def value=(new)
200:       if new != new.to_s and new.respond_to? :first
201:         super([new.first])
202:       else
203:         super([new.to_s])
204:       end
205:     end

[Validate]