Sha256: 09cb12cfd7fb124a4bfdfa669f36bcbf598a47afe8c67070e26fab50aea056d5

Contents?: true

Size: 545 Bytes

Versions: 8

Compression:

Stored size: 545 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

8 entries across 8 versions & 1 rubygems

Version Path
ruby-processing-2.7.1 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.7.0 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.18 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.17 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.16 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.15 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.14 lib/ruby-processing/helpers/camel_string.rb
ruby-processing-2.6.13 lib/ruby-processing/helpers/camel_string.rb