Class: Translatomatic::HTTP::FileParam
- Defined in:
- lib/translatomatic/http/file_param.rb
Overview
Formats the contents of a file or string for a multipart post
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#mime_type ⇒ Object
Returns the value of attribute mime_type.
Attributes inherited from Param
Instance Method Summary collapse
-
#initialize(key:, filename:, content:, mime_type:) ⇒ FileParam
constructor
A new instance of FileParam.
-
#to_s ⇒ String
Representation of this parameter as it appears within a multipart post request.
Constructor Details
#initialize(key:, filename:, content:, mime_type:) ⇒ FileParam
Returns a new instance of FileParam.
7 8 9 10 11 12 |
# File 'lib/translatomatic/http/file_param.rb', line 7 def initialize(key:, filename:, content:, mime_type:) @key = key @filename = filename @content = content @mime_type = mime_type end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'lib/translatomatic/http/file_param.rb', line 5 def content @content end |
#filename ⇒ Object
Returns the value of attribute filename.
5 6 7 |
# File 'lib/translatomatic/http/file_param.rb', line 5 def filename @filename end |
#mime_type ⇒ Object
Returns the value of attribute mime_type.
5 6 7 |
# File 'lib/translatomatic/http/file_param.rb', line 5 def mime_type @mime_type end |
Instance Method Details
#to_s ⇒ String
Returns Representation of this parameter as it appears within a multipart post request.
15 16 17 18 |
# File 'lib/translatomatic/http/file_param.rb', line 15 def to_s header(header_data) + header('Content-Type' => mime_type) + "\r\n#{content}\r\n" end |