Sha256: 39169114b76a9712d5495ea53bc0344f9b6b2476a0b9dad0a49276855151a125
Contents?: true
Size: 495 Bytes
Versions: 10
Compression:
Stored size: 495 Bytes
Contents
class Symbol # Generate a unique symbol. # # Symbol.generate #=> :"-1" # # If +key+ is given the new symbol will be prefixed with it. # # Symbol.generate(:foo) #=> :"foo-1" # # TODO: Is the generated symbol format acceptable? # # CREDIT: Trans def self.generate(key=nil) key = key.to_sym if key @symbol_generate_counter ||= {} @symbol_generate_counter[key] ||= 0 num = @symbol_generate_counter[key] += 1 ("#{key}-%X" % num).to_sym end end
Version data entries
10 entries across 9 versions & 2 rubygems