class Module def private_module_function(*symbol) module_function *symbol private_class_method *symbol end end if __FILE__ == $0 def show(code = nil) if code begin res = eval code, TOPLEVEL_BINDING rescue Exception => err res = err end puts "#{code}\t#=> #{res.inspect}" else puts end end show %{module M; def a() b() end; module_function :a; end} show %{module M; def b() end; ; end} show %{M.a} #=> NameError show show %{module M; def b() end; module_function :b; end} show %{M.a} #=> nil show %{M.b} #=> nil show show %{module M; def b() end; private_module_function :b; end} show %{M.b} #=> NameError end