Class: Merb::Test::MultipartRequestHelper::FileParam

Inherits:
Object
  • Object
show all
Defined in:
merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (FileParam) initialize(key, filename, content)

Returns a new instance of FileParam

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.



28
29
30
31
32
# File 'merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb', line 28

def initialize(key, filename, content)
  @key      = key
  @filename = filename
  @content  = content
end

Instance Attribute Details

- (Object) content

Returns the value of attribute content



23
24
25
# File 'merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb', line 23

def content
  @content
end

- (Object) filename

Returns the value of attribute filename



23
24
25
# File 'merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb', line 23

def filename
  @filename
end

- (Object) key

Returns the value of attribute key



23
24
25
# File 'merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb', line 23

def key
  @key
end

Instance Method Details

- (String) to_multipart

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

Returns:

  • (String)

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



36
37
38
# File 'merb-core/lib/merb-core/test/helpers/multipart_request_helper.rb', line 36

def to_multipart
  return %(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