Posted by p00ya on Fri 29th Jun 08:35
download | new post
- # Empties lines starting with a semicolon.
- class NoComments < File
- def gets(sep_string = $/)
- x = super.gets(sep_string)
- (/^;/ =~ x) ? '' : x
- end
- end
- # I was hoping this would work transparently, instead I get
- # private method `gets' called for "first_line_of_file\n"
- # when doing something like:
- io = NoComments.open("some_file", 'r')
- line = io.gets
Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.