Class: VoiceBase::Request::MultipartBuilder
- Inherits:
-
Object
- Object
- VoiceBase::Request::MultipartBuilder
- Defined in:
- lib/voicebase/request/multipart_builder.rb
Instance Attribute Summary collapse
-
#boundary ⇒ Object
Returns the value of attribute boundary.
-
#parts ⇒ Object
Returns the value of attribute parts.
Instance Method Summary collapse
- #add(part) ⇒ Object
- #body ⇒ Object
- #headers ⇒ Object
-
#initialize(headers:) ⇒ MultipartBuilder
constructor
A new instance of MultipartBuilder.
Constructor Details
#initialize(headers:) ⇒ MultipartBuilder
Returns a new instance of MultipartBuilder.
7 8 9 10 11 |
# File 'lib/voicebase/request/multipart_builder.rb', line 7 def initialize(headers:) @headers = headers @parts = [] @boundary = SecureRandom.hex end |
Instance Attribute Details
#boundary ⇒ Object
Returns the value of attribute boundary.
6 7 8 |
# File 'lib/voicebase/request/multipart_builder.rb', line 6 def boundary @boundary end |
#parts ⇒ Object
Returns the value of attribute parts.
6 7 8 |
# File 'lib/voicebase/request/multipart_builder.rb', line 6 def parts @parts end |
Instance Method Details
#add(part) ⇒ Object
13 14 15 |
# File 'lib/voicebase/request/multipart_builder.rb', line 13 def add(part) parts << part end |
#body ⇒ Object
17 18 19 |
# File 'lib/voicebase/request/multipart_builder.rb', line 17 def body "--#{boundary}\r\n#{multiparts}--#{boundary}--" end |
#headers ⇒ Object
21 22 23 |
# File 'lib/voicebase/request/multipart_builder.rb', line 21 def headers @headers.merge({"Content-Type" => "multipart/form-data; boundary=#{boundary}"}) end |