B
Berger, Daniel
Hi all,
From within a Ruby program, is there a way to get Ruby to re-read itself
from a specific part of the file? Let me explain. Say I have a method
"foo". I would like "foo" to slurp the rest of the script into memory
and write it to a file, possibly a temp file.
For example:
1: puts "Hello World"
2: foo()
3: puts "How's it going?"
In this script I would like lines 2 and 3 (or possibly just line 3 - I'm
not sure yet), but NOT line 1, read into memory and written to a file
(by the foo method). I thought perhaps there were some tricks I could
use with __DATA__, __END__ or __FILE__, but I wasn't sure.
Any ideas?
Regards,
Dan
From within a Ruby program, is there a way to get Ruby to re-read itself
from a specific part of the file? Let me explain. Say I have a method
"foo". I would like "foo" to slurp the rest of the script into memory
and write it to a file, possibly a temp file.
For example:
1: puts "Hello World"
2: foo()
3: puts "How's it going?"
In this script I would like lines 2 and 3 (or possibly just line 3 - I'm
not sure yet), but NOT line 1, read into memory and written to a file
(by the foo method). I thought perhaps there were some tricks I could
use with __DATA__, __END__ or __FILE__, but I wasn't sure.
Any ideas?
Regards,
Dan