diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 02:18:05 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-28 02:18:05 +0000 |
commit | 5fcaf1a3e82298a1252c0e06e8b93328e0a9bba3 (patch) | |
tree | 5c7b607e91899b50f693fb626b7e48f3cf59e109 | |
parent | 0ab07135c22370e38fedba81d43951a0691a2aa3 (diff) | |
download | ruby-5fcaf1a3e82298a1252c0e06e8b93328e0a9bba3.tar.gz ruby-5fcaf1a3e82298a1252c0e06e8b93328e0a9bba3.tar.xz ruby-5fcaf1a3e82298a1252c0e06e8b93328e0a9bba3.zip |
* golf_prelude.rb (Object.quine): get the script itself.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | golf_prelude.rb | 6 |
2 files changed, 10 insertions, 0 deletions
@@ -1,3 +1,7 @@ +Fri Dec 28 11:16:53 2007 NAKAMURA Usaku <usa@ruby-lang.org> + + * golf_prelude.rb (Object.quine): get the script itself. + Fri Dec 28 10:06:54 2007 Akinori MUSHA <knu@iDaemons.org> * golf_prelude.rb (Object.const_missing): Auto-complete constants. diff --git a/golf_prelude.rb b/golf_prelude.rb index 59b5ffc34..18b9f1b8d 100644 --- a/golf_prelude.rb +++ b/golf_prelude.rb @@ -1,3 +1,5 @@ +SCRIPT_LINES__={} + class Object def method_missing m, *a, &b r = /^#{m}/ @@ -14,6 +16,10 @@ class Object def h(a='H', b='w', c='!') puts "#{a}ello, #{b}orld#{c}" end + + def quine(src = $0) + SCRIPT_LINES__[src] + end end class Integer |