Sha256: 81b1f92f3a38fe22a3d4374e29b29750f41cf7ee45236d0e9ef0c9ec29cecaf3

Contents?: true

Size: 544 Bytes

Versions: 14

Compression:

Stored size: 544 Bytes

Contents

require 'forwardable'

# Avoid the monkey patching of String for camelize
class CamelString
  extend Forwardable
  def_delegators(:@string, *String.public_instance_methods(false))
  def initialize(str = 'no_name')
    @string = (str.length > 60) ? 'long_name' : str
  end

  def camelize(first_letter_in_uppercase = true)
    if first_letter_in_uppercase
      @string.gsub(%r{/(.?)}) { '::' + Regexp.last_match[1].upcase }
        .gsub(/(^|_)(.)/) { Regexp.last_match[2].upcase }
    else
      @string[0] + camelize[1..-1]
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
jruby_art-1.0.4 lib/jruby_art/helpers/camel_string.rb
jruby_art-1.0.3 lib/jruby_art/helpers/camel_string.rb
jruby_art-1.0.2 lib/jruby_art/helpers/camel_string.rb
jruby_art-1.0.1 lib/jruby_art/helpers/camel_string.rb
jruby_art-1.0.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.9.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.8.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.7.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.6.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.5.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.4.2 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.4.0 lib/jruby_art/helpers/camel_string.rb
jruby_art-0.3.1.pre lib/jruby_art/helpers/camel_string.rb
jruby_art-0.3.0.pre lib/jruby_art/helpers/camel_string.rb