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.



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

def initialize(block)
  @block = block
end

Instance Method Details

#write(data) ⇒ Object

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



153
154
155
156
# File 'lib/httpx/request/body.rb', line 153

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