Class: Translatomatic::HTTPRequest::FileParam

Inherits:
Param
  • Object
show all
Defined in:
lib/translatomatic/http_request.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.



100
101
102
103
104
105
# File 'lib/translatomatic/http_request.rb', line 100

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.



98
99
100
# File 'lib/translatomatic/http_request.rb', line 98

def content
  @content
end

#filenameObject

Returns the value of attribute filename.



98
99
100
# File 'lib/translatomatic/http_request.rb', line 98

def filename
  @filename
end

#mime_typeObject

Returns the value of attribute mime_type.



98
99
100
# File 'lib/translatomatic/http_request.rb', line 98

def mime_type
  @mime_type
end

Instance Method Details

#to_sObject



107
108
109
110
# File 'lib/translatomatic/http_request.rb', line 107

def to_s
  return header(header_data) +
    header("Content-Type": mime_type) + "\r\n#{content}\r\n"
end