This file is indexed.

/usr/lib/ruby/1.8/mechanize/form/select_list.rb is in libwww-mechanize-ruby1.8 1.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
class Mechanize
  class Form
    # 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
    class SelectList < MultiSelectList
      def initialize node
        super
        if selected_options.length > 1
          selected_options.reverse[1..selected_options.length].each do |o|
            o.unselect
          end
        end
      end

      ##
      # Find all options on this select list with +criteria+
      # Example:
      #   select_list.options_with(:value => /1|2/).each do |field|
      #     field.value = '20'
      #   end
      def options_with criteria
        criteria = {:name => criteria} if String === criteria
        f = @options.find_all do |thing|
          criteria.all? { |k,v| v === thing.send(k) }
        end
        yield f if block_given?
        f
      end

      ##
      # Find one option on this select list with +criteria+
      # Example:
      #   select_list.option_with(:value => '1').value = 'foo'
      def option_with criteria
        f = options_with(criteria).first
          yield f if block_given?
        f
      end

      def value
        value = super
        if value.length > 0
          value.last
        elsif @options.length > 0
          @options.first.value
        else
          nil
        end
      end

      def value=(new)
        if new != new.to_s and new.respond_to? :first
          super([new.first])
        else
          super([new.to_s])
        end
      end

      def query_value
        value ? [[name, value]] : nil
      end
    end
  end
end