Class: ReactOnRailsPro::RendererHttpClient::MultipartFileBody
- Inherits:
-
Object
- Object
- ReactOnRailsPro::RendererHttpClient::MultipartFileBody
- Defined in:
- lib/react_on_rails_pro/renderer_http_client.rb,
sig/react_on_rails_pro/renderer_http_client.rbs
Constant Summary collapse
- CHUNK_SIZE =
64 * 1024
Instance Method Summary collapse
- #bytesize ⇒ Integer?
- #close ⇒ nil
-
#initialize(body) ⇒ MultipartFileBody
constructor
A new instance of MultipartFileBody.
- #read ⇒ String?
Constructor Details
#initialize(body) ⇒ MultipartFileBody
Returns a new instance of MultipartFileBody.
113 114 115 116 117 |
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 113 def initialize(body) @body = body @io = nil @owns_io = false end |
Instance Method Details
#bytesize ⇒ Integer?
129 130 131 132 133 134 135 |
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 129 def bytesize return @body.size if @body.is_a?(Pathname) return unless @body.respond_to?(:size) position = @body.respond_to?(:pos) ? @body.pos : 0 @body.size - position end |
#close ⇒ nil
125 126 127 |
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 125 def close @io&.close if @owns_io && @io && !@io.closed? end |
#read ⇒ String?
119 120 121 122 123 |
# File 'lib/react_on_rails_pro/renderer_http_client.rb', line 119 def read io = opened_io chunk = io.read(CHUNK_SIZE) chunk&.b end |