devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Ruby Source Code Warehouse" project. The intent of this project is to help you "Learn Ruby by Example" TM.

Other links

The source code

# Copyritght (c) 2002 TANIGUCHI Takaki
# This program is distributed under the GNU GPL 2 or later.

require 'cgi'

class CGI
  def multipart?
    if ENV['CONTENT_TYPE'].nil? or
	ENV['CONTENT_TYPE'].index(%r|\Amultipart/form-data|).nil?
      return false
    else
      return true
    end
  end
  private :multipart?
  def value(key)
    val = @params[key]
    ret = val.collect{|v|
      multipart?() ? v.read : v
    }
    # ret.size == 1 ? ret[0] : ret
  end
  def original_filename(key)
    ret = @params[key].collect{|f|
      f.original_filename
    }
    # ret.size == 1 ? ret[0] : ret
  end
  def content_type(key)
    ret = @params[key].collect{|f|
      f.content_type
    }
    # ret.size == 1 ? ret[0] : ret
  end
end




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com