Created
April 2, 2016 12:36
-
-
Save ggrossetie/7f0c7acf4c94f3002c6422ac26572d67 to your computer and use it in GitHub Desktop.
This file contains 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