Class: Multipart::Post::Parts::ParamPart
- Inherits:
-
Object
- Object
- Multipart::Post::Parts::ParamPart
- Includes:
- Part
- Defined in:
- lib/multipart/post/parts.rb
Overview
Represents a parametric part to be filled with given value.
Instance Method Summary collapse
- #build_part(boundary, name, value, headers = {}) ⇒ Object
-
#initialize(boundary, name, value, headers = {}) ⇒ ParamPart
constructor
A new instance of ParamPart.
- #length ⇒ Object
Methods included from Part
Constructor Details
#initialize(boundary, name, value, headers = {}) ⇒ ParamPart
Returns a new instance of ParamPart.
58 59 60 61 |
# 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 |
Instance Method Details
#build_part(boundary, name, value, headers = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 |
# 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 ⇒ Object
63 64 65 |
# File 'lib/multipart/post/parts.rb', line 63 def length @part.bytesize end |