class Merb::Test::MultipartRequestHelper::FileParam

Attributes

content[RW]
filename[RW]
key[RW]

Public Class Methods

new(key, filename, content) click to toggle source

Parameters

key<~to_s>

The parameter key.

filename<~to_s>

Name of the file for this parameter.

content<~to_s>

Content of the file for this parameter.

# File lib/merb-core/test/helpers/multipart_request_helper.rb, line 30
def initialize(key, filename, content)
  @key      = key
  @filename = filename
  @content  = content
end

Public Instance Methods

to_multipart() click to toggle source

Returns

String

The file parameter in a form suitable for a multipart request.

# File lib/merb-core/test/helpers/multipart_request_helper.rb, line 39
def to_multipart
  return %Q(Content-Disposition: form-data; name="#{key}"; filename="#{filename}"\r\n) + "Content-Type: #{MIME::Types.type_for(@filename).first}\r\n\r\n" + content + "\r\n"
end