-
-
Save elia/ed66eeac3930a4000666def4efd9e71d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class IO | |
def read | |
if @eof | |
'' | |
else | |
`res = self.read_proc(@path)` | |
@eof = true | |
@lineno = res.size | |
res | |
end | |
end | |
end | |
FILE_READER = IO.new | |
def file_read(path) | |
File.read(@path) | |
end | |
FILE_READER.read_proc = file_read | |
FILE_READER.extend(IO::Readable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment