# TITLE: # # Symbol Generation # # DESCRIPTION: # # Symbol generation extensions. # # AUTHORS: # # CREDIT Thomas Sawyer # # NOTES: # # TODO Is Symbol#chomp worth having? Are the any other # String methods that Symbols really should have too? # class Symbol # Generate a unique symbol. # # Symbol.generate => :<1> # # If +suffix+ is given the new symbol will be suffixed with it. # # Symbol.generate(:this) => :<2>this # #-- # TODO Is the generated symbol format acceptable? #++ def self.generate(suffix=nil) @symbol_generate_counter ||= 0 ("<%X>#{suffix}" % @symbol_generate_counter += 1).to_sym end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TestSymbol < Test::Unit::TestCase def test_generate assert_equal( Symbol.generate, :'<1>' ) end end =end