Mechanize::Form::SelectList

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

Public Class Methods

new(node) click to toggle source
    # File lib/mechanize/form/select_list.rb, line 11
11:   def initialize node
12:     super
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

Public Instance Methods

query_value() click to toggle source
    # File lib/mechanize/form/select_list.rb, line 39
39:   def query_value
40:     value ? [[name, value]] : nil
41:   end
value() click to toggle source
    # File lib/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
value=(new) click to toggle source
    # File lib/mechanize/form/select_list.rb, line 31
31:   def value=(new)
32:     if new != new.to_s and new.respond_to? :first
33:       super([new.first])
34:     else
35:       super([new.to_s])
36:     end
37:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.