Class: Net::HTTP::Post::ParamPart

Inherits:
Object
  • Object
show all
Includes:
Part
Defined in:
lib/net/http/post/multipart.rb

Overview

Represents a part to be filled with a string name/value pair.

Instance Method Summary collapse

Methods included from Part

#length, new, #to_io

Constructor Details

#initialize(boundary, name, value) ⇒ ParamPart

Returns a new instance of ParamPart.



36
37
38
39
# File 'lib/net/http/post/multipart.rb', line 36

def initialize(boundary, name, value)
  @part = build_part(boundary, name, value)
  @io = StringIO.new(@part)
end

Instance Method Details

#build_part(boundary, name, value) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/net/http/post/multipart.rb', line 41

def build_part(boundary, name, value)
  part = ''
  part << "--#{boundary}\r\n"
  part << "Content-Disposition: form-data; name=\"#{name.to_s}\"\r\n"
  part << "\r\n"
  part << "#{value}\r\n"
end