lib/refinements/ios.rb in refinements-9.5.0 vs lib/refinements/ios.rb in refinements-9.6.0

- old
+ new

@@ -1,7 +1,9 @@ # frozen_string_literal: true +require "refinements/shared/ios/reread" + module Refinements # Provides additional enhancements to the IO primitive. module IOs refine IO.singleton_class do def void @@ -13,19 +15,19 @@ end end end refine IO do + import_methods Shared::IOs::Reread + def redirect other return self unless block_given? backup = dup reopen other yield self reopen backup end - - def reread(length = nil, buffer: nil) = tap(&:rewind).read(length, buffer) def squelch(&) = self.class.void.then { |void| redirect(void, &) } end end end