Sha256: 8b54b4ed37ab6e920302a48e9943d57944c5d517a5564012e6a766f8a9238adb

Contents?: true

Size: 520 Bytes

Versions: 3

Compression:

Stored size: 520 Bytes

Contents

# Taken from ActiveSupport
class String
  def camelize(first_letter_in_uppercase = true)
    if first_letter_in_uppercase
      self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
    else
      self.first.downcase + camelize(self)[1..-1]
    end
  end
  
  def classify
    camelize(self.sub(/.*\./, ''))
  end
  
  def underscore
    self.gsub(/::/, '/').
         gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
         gsub(/([a-z\d])([A-Z])/,'\1_\2').
         tr("-", "_").
         downcase
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
bmabey-rosetta_queue-0.1.3 lib/rosetta_queue/core_ext/string.rb
bmabey-rosetta_queue-0.2.0 lib/rosetta_queue/core_ext/string.rb
cwyckoff-rosetta_queue-0.3.3 lib/rosetta_queue/core_ext/string.rb