Class: HTTPX::ProcIO

Inherits:
Object
  • Object
show all
Defined in:
lib/httpx/request/body.rb

Overview

Wrapper yielder which can be used with functions which expect an IO writer.

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ ProcIO

Returns a new instance of ProcIO.



144
145
146
# File 'lib/httpx/request/body.rb', line 144

def initialize(block)
  @block = block
end

Instance Method Details

#write(data) ⇒ Object

Implementation the IO write protocol, which yield the given chunk to @block.



149
150
151
152
# File 'lib/httpx/request/body.rb', line 149

def write(data)
  @block.call(data.dup)
  data.bytesize
end