Sha256: 89b608c9fa951faa40fd44f7e49881943abd16c133350ed3c721cdaafcd2370a

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module WWW
  class Mechanize
    # This class is deprecated and will be removed in Mechanize version 0.9.0
    class List < Array
      @@notified = false

      # This method provides syntax sugar so that you can write expressions
      # like this:
      #  form.fields.with.name('foo').and.href('bar.html')
      #
      def with
        if !@@notified
          $stderr.puts("This method is deprecated and will be removed in version 0.9.0.  Please use: *_with(:#{meth_sym} => #{args.first ? args.first.inspect : 'nil'})")
          @@notified = true
        end
        self
      end

      def value=(arg)
        if !@@notified
          $stderr.puts("This method is deprecated and will be removed in version 0.9.0.  Please use: *_with(:#{meth_sym} => #{args.first ? args.first.inspect : 'nil'})")
          @@notified = true
        end
        first().value=(arg)
      end

      alias :and :with

      def respond_to?(method_sym)
        first.respond_to?(method_sym)
      end

      def method_missing(meth_sym, *args)
        if !@@notified
          $stderr.puts("This method is deprecated and will be removed in version 0.9.0.  Please use: *_with(:#{meth_sym} => #{args.first ? args.first.inspect : 'nil'})")
          @@notified = true
        end
        if length > 0
          return first.send(meth_sym) if args.empty?
          arg = args.first
          if arg.class == Regexp
            WWW::Mechanize::List.new(find_all { |e| e.send(meth_sym) =~ arg })
          else
            WWW::Mechanize::List.new(find_all { |e| e.send(meth_sym) == arg })
          end
        else
          ''
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mechanize-0.8.5 lib/www/mechanize/list.rb