File: file_upload.rb

package info (click to toggle)
libwww-mechanize-ruby 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 956 kB
  • ctags: 883
  • sloc: ruby: 6,621; makefile: 4
file content (23 lines) | stat: -rw-r--r-- 736 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class Mechanize
  class Form
    # This class represents a file upload field found in a form.  To use this
    # class, set FileUpload#file_data= to the data of the file you want
    # to upload and FileUpload#mime_type= to the appropriate mime type
    # of the file.
    # See the example in EXAMPLES[link://files/EXAMPLES_txt.html]
    class FileUpload < Field
      attr_accessor :file_name # File name
      attr_accessor :mime_type # Mime Type (Optional)

      alias :file_data :value
      alias :file_data= :value=

        def initialize node, file_name
          @file_name = Util.html_unescape(file_name)
          @file_data = nil
          @node      = node
          super(node, @file_data)
        end
    end
  end
end