Class: Parts::ParamPart
- Inherits:
-
Object
- Object
- Parts::ParamPart
- Includes:
- Part
- Defined in:
- lib/tent-client/multipart-post/parts.rb
Instance Method Summary collapse
- #build_part(boundary, name, value, options = {}) ⇒ Object
-
#initialize(boundary, name, value, options = {}) ⇒ ParamPart
constructor
A new instance of ParamPart.
- #length ⇒ Object
Methods included from Part
Constructor Details
#initialize(boundary, name, value, options = {}) ⇒ ParamPart
Returns a new instance of ParamPart.
26 27 28 29 |
# File 'lib/tent-client/multipart-post/parts.rb', line 26 def initialize(boundary, name, value, = {}) @part = build_part(boundary, name, value, ) @io = StringIO.new(@part) end |
Instance Method Details
#build_part(boundary, name, value, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tent-client/multipart-post/parts.rb', line 35 def build_part(boundary, name, value, = {}) part = [] part << "--#{boundary}" part << %(Content-Disposition: form-data; name="#{name.to_s}") ([:headers] || {}).each do |name, value| part << "#{name}: #{value}" end part.join("\r\n") << "\r\n\r\n" part << "#{value}\r\n" end |
#length ⇒ Object
31 32 33 |
# File 'lib/tent-client/multipart-post/parts.rb', line 31 def length @part.bytesize end |