Module: Nuggets::IO::RedirectMixin
- Included in:
- IO
- Defined in:
- lib/nuggets/io/redirect_mixin.rb
Instance Method Summary collapse
Instance Method Details
#redirect(target = NullMixin::NULL, mode = 'w') ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nuggets/io/redirect_mixin.rb', line 33 def redirect(target = NullMixin::NULL, mode = 'w') unless target.is_a?(self.class) target = ::File.open(target, mode) close_target = true end prev = dup reopen(target) yield ensure reopen(prev) if prev target.close if close_target end |