Class: Translatomatic::HTTP::FileParam

Inherits:
Param
  • Object
show all
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

Attributes inherited from Param

#key, #value

Instance Method Summary collapse

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

#contentObject

Returns the value of attribute content.



5
6
7
# File 'lib/translatomatic/http/file_param.rb', line 5

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



5
6
7
# File 'lib/translatomatic/http/file_param.rb', line 5

def filename
  @filename
end

#mime_typeObject

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_sString

Returns Representation of this parameter as it appears within a multipart post request.

Returns:

  • (String)

    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