Class: Parts::ParamPart

Inherits:
Object
  • Object
show all
Includes:
Part
Defined in:
lib/parts.rb

Instance Method Summary collapse

Methods included from Part

new, #to_io

Constructor Details

#initialize(boundary, name, value) ⇒ ParamPart

Returns a new instance of ParamPart.



28
29
30
31
# File 'lib/parts.rb', line 28

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



37
38
39
40
41
42
43
# File 'lib/parts.rb', line 37

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

#lengthObject



33
34
35
# File 'lib/parts.rb', line 33

def length
 @part.bytesize
end