Class: WEBrick::HTTPUtils::FormData
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
| Class Chain: 
          self,
          String
         | |
| Instance Chain: 
          self,
          String
         | |
| Inherits: | String 
 | 
| Defined in: | lib/webrick/httputils.rb | 
Overview
Stores multipart form data.  FormData objects are created when parse_form_data is called.
Class Method Summary
- 
    
      .new(*args)  ⇒ FormData 
    
    constructor
    Creates a new FormDataobject.
Instance Attribute Summary
Instance Method Summary
- 
    
      #<<(str)  
    
    Adds strto thisFormDatawhich may be the body, a header or a header entry.
- 
    
      #[](*key)  
    
    Retrieves the header at the first entry in key
- 
    
      #append_data(data)  
    
    Adds dataat the end of the chain of entries.
- 
    
      #each_data  
    
    Yields each entry in this FormData.
- 
    
      #list  
      (also: #to_ary)
    
    Returns all the FormDataas an Array.
- 
    
      #to_ary  
    
    A FormData will behave like an Array. 
- 
    
      #to_s  
    
    This FormData's body. 
Constructor Details
    .new(*args)  ⇒ FormData 
  
Creates a new FormData object.
args is an Array of form data entries.  One FormData will be created for each entry.
This is called by WEBrick::HTTPUtils.parse_form_data for you
# File 'lib/webrick/httputils.rb', line 265
def initialize(*args) @name = @filename = @next_data = nil if args.empty? @raw_header = [] @header = nil super("") else @raw_header = EmptyRawHeader @header = EmptyHeader super(args.shift) unless args.empty? @next_data = self.class.new(*args) end end end
Instance Attribute Details
#filename (rw)
The filename of the form data part
# File 'lib/webrick/httputils.rb', line 252
attr_accessor :filename
#name (rw)
The name of the form data part
# File 'lib/webrick/httputils.rb', line 247
attr_accessor :name
Instance Method Details
#<<(str)
Adds str to this FormData which may be the body, a header or a header entry.
This is called by WEBrick::HTTPUtils.parse_form_data for you
# File 'lib/webrick/httputils.rb', line 298
def <<(str) if @header super elsif str == CRLF @header = HTTPUtils::parse_header(@raw_header.join) if cd = self['content-disposition'] if /\s+name="(.*?)"/ =~ cd then @name = $1 end if /\s+filename="(.*?)"/ =~ cd then @filename = $1 end end else @raw_header << str end self end
#[](*key)
Retrieves the header at the first entry in key
# File 'lib/webrick/httputils.rb', line 284
def [](*key) begin @header[key[0].downcase].join(", ") rescue StandardError, NameError super end end
#append_data(data)
Adds data at the end of the chain of entries
This is called by WEBrick::HTTPUtils.parse_form_data for you.
#each_data
Yields each entry in this FormData
#list Also known as: #to_ary
Returns all the FormData as an Array
#to_ary
A FormData will behave like an Array
# File 'lib/webrick/httputils.rb', line 356
alias :to_ary :list
#to_s
This FormData's body
# File 'lib/webrick/httputils.rb', line 361
def to_s String.new(self) end