Class: FileParam
- Inherits:
-
Object
- Object
- FileParam
- Defined in:
- lib/mime_parts.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
A new instance of FileParam.
- #to_multipart ⇒ Object
Constructor Details
#initialize(key, filename, content) ⇒ FileParam
Returns a new instance of FileParam.
18 19 20 |
# File 'lib/mime_parts.rb', line 18 def initialize( key, filename, content ) @key = key; @filename = filename; @content = content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
17 18 19 |
# File 'lib/mime_parts.rb', line 17 def content @content end |
#filename ⇒ Object
Returns the value of attribute filename.
17 18 19 |
# File 'lib/mime_parts.rb', line 17 def filename @filename end |
#key ⇒ Object
Returns the value of attribute key.
17 18 19 |
# File 'lib/mime_parts.rb', line 17 def key @key end |
Instance Method Details
#to_multipart ⇒ Object
22 23 24 25 26 |
# File 'lib/mime_parts.rb', line 22 def to_multipart return "Content-Disposition: form-data; name=\"#{CGI::escape(key)}\"; filename=\"#{filename}\"\r\n" + "Content-Transfer-Encoding: binary\r\n" + "Content-type: #{MIME::Types.type_for(filename)}\r\n\r\n" + content + "\r\n" end |