Sha256: fb4ee93949e22fba5bb55573174dfe290032b2fd9bd878244ed34c933d91565e
Contents?: true
Size: 659 Bytes
Versions: 7
Compression:
Stored size: 659 Bytes
Contents
# frozen_string_literal: true require 'stringio' module NanoBot module Components class Stream < StringIO def write(*args) if @callback @accumulated += args.first @callback.call(@accumulated, args.first, false) end super end def callback=(block) @accumulated = '' @callback = block end def finish flush result = string.clone truncate(0) rewind if @callback @callback.call(@accumulated, nil, true) @callback = nil @accumulated = nil end result end end end end
Version data entries
7 entries across 7 versions & 1 rubygems