lib/rio/ioh.rb in rio-0.5.1 vs lib/rio/ioh.rb in rio-0.6.0

- old
+ new

@@ -1,8 +1,8 @@ #-- # =========================================================================== -# Copyright (c) 2005-2012 Christopher Kleckner +# Copyright (c) 2005-2017 Christopher Kleckner # All rights reserved # # This file is part of the Rio library for ruby. # # Rio is free software; you can redistribute it and/or modify @@ -33,11 +33,10 @@ @ios = ios end def initialize_copy(other) #p callstr('ioh:initialize_copy',other) super - #p @ios @ios = other.ios.clone unless other.ios.nil? end def callstr(func,*args) self.class.to_s+'['+self.to_s+']'+'.'+func.to_s+'('+args.join(',')+')' end @@ -88,20 +87,43 @@ break unless s = handle.read(nb) yield s end self end - extend Forwardable - def_instance_delegators(:handle,:binmode,:stat,:rewind, - :each,:each_byte,:gets,:getc, - :each_line, - :read,:readlines,:readline,:sysread, - :<<,:print,:printf,:putc,:write,:syswrite, - :pos,:pos=,:lineno,:lineno=, - :fileno, - :close_read,:close_write, - :fsync,:sync,:sync=,:fcntl,:ioctl) + extend RIO::Fwd + + fwd_readers :handle, + :binmode, + :stat, + :rewind, + :each, + :each_byte, + :gets, + :getc, + :each_line, + :read, + :readlines, + :readline, + :sysread, + :print, + :printf, + :putc, + :write, + :syswrite, + :fileno, + :close_read, + :close_write, + :fsync, + :fcntl, + :ioctl, + :<< + + fwd :handle, + :pos, + :lineno, + :sync + def set_encoding(*args) handle.set_encoding(*args) end def method_missing(sym,*args,&block) @@ -139,25 +161,21 @@ ios = nil end end def closed?() ios.nil? end def each(&block) - #p handle while filename = handle.read - #p "IOH: #{filename.inspect} FS_ENCODING=#{FS_ENCODING}" - #yield filename.force_encoding(FS_ENCODING) yield filename end end - def each0(&block) - handle.each { |filename| - yield filename - } - end - extend Forwardable - def_instance_delegators(:handle, - :read, - :pos,:pos=,:tell,:seek,:rewind) + + extend RIO::Fwd + fwd :handle, :pos + fwd_readers :handle, + :read, + :tell, + :seek, + :rewind end end end __END__