Method: Vips::TargetCustom#on_write

Defined in:
lib/vips/targetcustom.rb

#on_write {|bytes| ... } ⇒ Object

The block is executed to write data to the source. The interface is exactly as IO::write, ie. it should write the string and return the number of bytes written.

Yield Parameters:

  • bytes (String)

    Write these bytes to the file

Yield Returns:

  • (Integer)

    The number of bytes written, or -1 on error



59
60
61
62
63
64
65
66
67
# File 'lib/vips/targetcustom.rb', line 59

def on_write &block
  signal_connect "write" do |p, len|
    chunk = p.get_bytes(0, len)
    bytes_written = block.call chunk
    chunk.clear

    bytes_written
  end
end