Sha256: d793d4e29652a758b31185dfc9c4cfb0967e42587a5d17244313ba27f72dac80

Contents?: true

Size: 443 Bytes

Versions: 4

Compression:

Stored size: 443 Bytes

Contents

# used from ActiveSupport
# Copyright (c) 2005-2009 David Heinemeier Hansson

class String
  
  def underscore
    self.gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end
  
  def camelize
    self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  end
  
  def humanize
    self.gsub(/_id$/, "").gsub(/_/, " ").capitalize
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
pjdavis-roart-0.1.3 lib/roart/core/string.rb
pjdavis-roart-0.1.4 lib/roart/core/string.rb
threetee-roart-0.1.4 lib/roart/core/string.rb
roart-0.1.4 lib/roart/core/string.rb