class Multipart::Post::Parts::ParamPart
Represents a parametric part to be filled with given value.
Public Class Methods
new(boundary, name, value, headers = {})
click to toggle source
@param boundary [String] @param name [#to_s] @param value [String] @param headers [Hash] Content-Type and Content-ID are used, if present.
# File lib/multipart/post/parts.rb, line 58 def initialize(boundary, name, value, headers = {}) @part = build_part(boundary, name, value, headers) @io = StringIO.new(@part) end
Public Instance Methods
build_part(boundary, name, value, headers = {})
click to toggle source
@param boundary [String] @param name [#to_s] @param value [String] @param headers [Hash] Content-Type is used, if present.
# File lib/multipart/post/parts.rb, line 71 def build_part(boundary, name, value, headers = {}) part = String.new part << "--#{boundary}\r\n" part << "Content-ID: #{headers["Content-ID"]}\r\n" if headers["Content-ID"] part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n" part << "Content-Type: #{headers["Content-Type"]}\r\n" if headers["Content-Type"] part << "\r\n" part << "#{value}\r\n" end
length()
click to toggle source
# File lib/multipart/post/parts.rb, line 63 def length @part.bytesize end