Sha256: 306c5bff6d7f97e2bf044f9e91b47729d46164f76956e2dad92e7798a4eb1707
Contents?: true
Size: 773 Bytes
Versions: 1
Compression:
Stored size: 773 Bytes
Contents
require 'stringio' module IPFS; end module IPFS::IO # :nodoc: class ReadFromWriterIO # :nodoc: def initialize &block @block = block @stream = StringIO.new fetch_data end def read length = nil, outbuf = '' return nil if @stream.size == 0 outbuf.slice!(length..-1) if !length.nil? q = 0 while @stream.size > 0 s = @stream.size - @p s = [length - q, s].min if !length.nil? outbuf[q, s] = @stream.string[@p, s] @p += s q += s break if q == length fetch_data if @stream.size == @p end outbuf end private def fetch_data @p = 0 @stream.string = "" @block.call @stream if not @stream.closed? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ipfs-api-0.1.0 | lib/ipfs-api/io.rb |