Class: Merb::Test::MultipartRequestHelper::FileParam
- Defined in:
- lib/merb-core/test/helpers/multipart_request_helper.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key, filename, content) ⇒ FileParam
constructor
Parameters key<~to_s>:: The parameter key.
-
#to_multipart ⇒ Object
Returns String:: The file parameter in a form suitable for a multipart request.
Constructor Details
#initialize(key, filename, content) ⇒ 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.
30 31 32 33 34 |
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 30 def initialize(key, filename, content) @key = key @filename = filename @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
24 25 26 |
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24 def content @content end |
#filename ⇒ Object
Returns the value of attribute filename.
24 25 26 |
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24 def filename @filename end |
#key ⇒ Object
Returns the value of attribute key.
24 25 26 |
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 24 def key @key end |
Instance Method Details
#to_multipart ⇒ Object
Returns
- String
-
The file parameter in a form suitable for a multipart request.
39 40 41 |
# File 'lib/merb-core/test/helpers/multipart_request_helper.rb', line 39 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 |