1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
class InputStream include Enumerable # # from String#each def each(&block) self.rewind while pos = self.byteindex(0x0a) block.call(self.read(pos+1)) end rest = self.read() if rest block.call(rest) end end end