Class Index [+]

Quicksearch

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 10
10:       def initialize node
11:         super
12:         if selected_options.length > 1
13:           selected_options.reverse[1..selected_options.length].each do |o|
14:             o.unselect
15:           end
16:         end
17:       end

Public Instance Methods

option_with(criteria) click to toggle source

Find one option on this select list with criteria Example:

  select_list.option_with(:value => '1').value = 'foo'
    # File lib/mechanize/form/select_list.rb, line 38
38:       def option_with criteria
39:         f = options_with(criteria).first
40:           yield f if block_given?
41:         f
42:       end
options_with(criteria) click to toggle source

Find all options on this select list with criteria Example:

  select_list.options_with(:value => /1|2/).each do |field|
    field.value = '20'
  end
    # File lib/mechanize/form/select_list.rb, line 25
25:       def options_with criteria
26:         criteria = {:name => criteria} if String === criteria
27:         f = @options.find_all do |thing|
28:           criteria.all? { |k,v| v === thing.send(k) }
29:         end
30:         yield f if block_given?
31:         f
32:       end
query_value() click to toggle source
    # File lib/mechanize/form/select_list.rb, line 63
63:       def query_value
64:         value ? [[name, value]] : nil
65:       end
value() click to toggle source
    # File lib/mechanize/form/select_list.rb, line 44
44:       def value
45:         value = super
46:         if value.length > 0
47:           value.last
48:         elsif @options.length > 0
49:           @options.first.value
50:         else
51:           nil
52:         end
53:       end
value=(new) click to toggle source
    # File lib/mechanize/form/select_list.rb, line 55
55:       def value=(new)
56:         if new != new.to_s and new.respond_to? :first
57:           super([new.first])
58:         else
59:           super([new.to_s])
60:         end
61:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.