summaryrefslogtreecommitdiff
path: root/golf_prelude.rb
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 01:07:21 (GMT)
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-28 01:07:21 (GMT)
commitf1ddd69d7bb8fa6af0f4306edea238fa97a2e941 (patch)
tree8de457dd17da2696d627ba9d951d1152ed19a54f /golf_prelude.rb
parent3b83e10790dac26481242077ee51fc2187b8eefb (diff)
* golf_prelude.rb (Object.const_missing): Auto-complete constants.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'golf_prelude.rb')
-rw-r--r--golf_prelude.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/golf_prelude.rb b/golf_prelude.rb
index 602767a..59b5ffc 100644
--- a/golf_prelude.rb
+++ b/golf_prelude.rb
@@ -5,6 +5,12 @@ class Object
t ? __send__(t, *a, &b) : super
end
+ def self.const_missing c
+ r = /^#{c}/
+ t = constants.sort.find{|e|r=~e}
+ t ? const_get(t) : superclass.const_get(c)
+ end
+
def h(a='H', b='w', c='!')
puts "#{a}ello, #{b}orld#{c}"
end