Class: HTTPX::Transcoder::Multipart::Encoder
- Inherits:
-
Object
- Object
- HTTPX::Transcoder::Multipart::Encoder
- Defined in:
- lib/httpx/transcoder/multipart/encoder.rb,
sig/transcoder/multipart.rbs
Instance Attribute Summary collapse
-
#bytesize ⇒ Integer
readonly
Returns the value of attribute bytesize.
Instance Method Summary collapse
Instance Attribute Details
#bytesize ⇒ Integer (readonly)
Returns the value of attribute bytesize.
6 7 8 |
# File 'lib/httpx/transcoder/multipart/encoder.rb', line 6 def bytesize @bytesize end |
Instance Method Details
#content_type ⇒ String
18 19 20 |
# File 'lib/httpx/transcoder/multipart/encoder.rb', line 18 def content_type "multipart/form-data; boundary=#{@boundary}" end |
#read(length = nil, outbuf = nil) ⇒ String?
28 29 30 31 32 33 34 35 |
# File 'lib/httpx/transcoder/multipart/encoder.rb', line 28 def read(length = nil, outbuf = nil) data = String(outbuf).clear.force_encoding(Encoding::BINARY) if outbuf data ||= "".b read_chunks(data, length) data unless length && data.empty? end |
#rewind ⇒ void
This method returns an undefined value.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/httpx/transcoder/multipart/encoder.rb', line 37 def rewind form = @form.each_with_object([]) do |(key, val), aux| if val.respond_to?(:path) && val.respond_to?(:reopen) && val.respond_to?(:closed?) && val.closed? # @type var val: File val = val.reopen(val.path, File::RDONLY) end val.rewind if val.respond_to?(:rewind) aux << [key, val] end @form = form @bytesize = 0 @parts = to_parts(form) @part_index = 0 end |
#to_s ⇒ String
22 23 24 25 26 |
# File 'lib/httpx/transcoder/multipart/encoder.rb', line 22 def to_s read || "" ensure rewind end |