Sha256: 928af3c50ee0349a3b223b85655575ef64b2c0da0be9d0a9ff02de1eb7aad144
Contents?: true
Size: 626 Bytes
Versions: 26
Compression:
Stored size: 626 Bytes
Contents
class String # Variation of coverting a string to camelcase. This is unlike # #camelcase in that it is geared toward code reflection use. # # "this/is_a_test".camelize #=> This::IsATest # def camelize #to_s.gsub(/(^|_)(.)/){$2.upcase} to_s.gsub(/\/(.?)/){ "::" + $1.upcase }.gsub(/(^|_)(.)/){ $2.upcase } end end # _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # =begin test require 'test/unit' class TCString < Test::Unit::TestCase def test_camelize assert_equal( 'ThisIsIt', 'this_is_it'.camelize ) end end =end
Version data entries
26 entries across 26 versions & 1 rubygems