Sha256: c8d5b393ceb353d555655c7843877ee8a22fe7d5b0e2201a11f737499bad5401
Contents?: true
Size: 691 Bytes
Versions: 13
Compression:
Stored size: 691 Bytes
Contents
module Kernel # Generates a new symbol that is unique among the # method names of the object. If a name argument # is given, it will generate a similar name. # # Class.generate_method_name( :class ) => :_clast_ # def generate_method_name( name='a' ) s = name.to_s while self.respond_to?( "_#{s}_" ) s = s.succ end return "_#{s}_".to_sym end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCKernel < Test::Unit::TestCase def test_generate_method_name assert_equal( :_foo_, @t.generate_method_name( :foo ) ) end end =end
Version data entries
13 entries across 13 versions & 1 rubygems