Sha256: b6e52f35862fda5bb4b6df067c8116983dd7d1970dc7a5c21e9068b54b1e849f

Contents?: true

Size: 409 Bytes

Versions: 8

Compression:

Stored size: 409 Bytes

Contents

module TensorStream
  module StringHelper
    def camelize(string, uppercase_first_letter = true)
      string = if uppercase_first_letter
                 string.sub(/^[a-z\d]*/) { $&.capitalize }
               else
                 string.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase }
               end
      string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::')
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tensor_stream-0.6.1 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.6.0 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.5.1 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.5.0 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.4.1 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.4.0 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.3.0 lib/tensor_stream/helpers/string_helper.rb
tensor_stream-0.2.0 lib/tensor_stream/helpers/string_helper.rb