diff --git a/ChangeLog b/ChangeLog index 2c595b408dd31a..78afdf8cf36c7f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Fri Dec 28 10:06:54 2007 Akinori MUSHA + + * golf_prelude.rb (Object.const_missing): Auto-complete constants. + Fri Dec 28 01:55:04 2007 Nobuyoshi Nakada * transcode.c (transcode_dispatch): allows transcoding from/to diff --git a/golf_prelude.rb b/golf_prelude.rb index 602767a5de9232..59b5ffc345f7fe 100644 --- a/golf_prelude.rb +++ b/golf_prelude.rb @@ -5,6 +5,12 @@ def method_missing m, *a, &b 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