class Translatomatic::HTTP::Param
Formats a basic string key/value pair for a multipart post
Attributes
key[RW]
value[RW]
Public Class Methods
new(key:, value:)
click to toggle source
# File lib/translatomatic/http/param.rb, line 7 def initialize(key:, value:) @key = key @value = value end
Public Instance Methods
to_s()
click to toggle source
@return [String] Representation of this parameter as it appears
within a multipart post request.
# File lib/translatomatic/http/param.rb, line 14 def to_s header(header_data) + "\r\n#{value}\r\n" end
Private Instance Methods
header(options)
click to toggle source
# File lib/translatomatic/http/param.rb, line 25 def header(options) out = [] idx = 0 options.each do |key, value| separator = idx.zero? ? ': ' : '=' out << "#{key}#{separator}#{value}" idx += 1 end out.join('; ') + "\r\n" end
header_data()
click to toggle source
# File lib/translatomatic/http/param.rb, line 20 def header_data name = CGI.escape(key.to_s) { 'Content-Disposition' => 'form-data', name: %("#{name}") } end