Class: Datadog::Core::Vendor::Multipart::Post::Parts::ParamPart
- Inherits:
-
Object
- Object
- Datadog::Core::Vendor::Multipart::Post::Parts::ParamPart
- Includes:
- Part
- Defined in:
- lib/datadog/core/vendor/multipart-post/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.
44 45 46 47 |
# File 'lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb', line 44 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
57 58 59 60 61 62 63 64 65 |
# File 'lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb', line 57 def build_part(boundary, name, value, headers = {}) part = '' 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
49 50 51 |
# File 'lib/datadog/core/vendor/multipart-post/multipart/post/parts.rb', line 49 def length @part.bytesize end |