Sha256: b3b781aedd7d206e6dd9c67033158a1dbc0d8526a7ff39d311c1b1626662035e
Contents?: true
Size: 658 Bytes
Versions: 61
Compression:
Stored size: 658 Bytes
Contents
require 'tins/temp_io' module Tins module TempIO class Enum < Enumerator include Tins::TempIO def initialize(chunk_size: 2 ** 16, filename: nil, &content_proc) content_proc or raise ArgumentError, 'need a content proc as block argument' super() do |y| temp_io(name: 'some-stream', content: content_proc) do |file| until file.eof? y.yield file.read(chunk_size) end end end.tap do |enum| if filename enum.define_singleton_method(:filename) do filename end end end end end end end
Version data entries
61 entries across 51 versions & 2 rubygems