Skip to content

Instantly share code, notes, and snippets.

@ggrossetie
Created April 2, 2016 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ggrossetie/7f0c7acf4c94f3002c6422ac26572d67 to your computer and use it in GitHub Desktop.
Save ggrossetie/7f0c7acf4c94f3002c6422ac26572d67 to your computer and use it in GitHub Desktop.
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