Sha256: 56c5ba75d60d52de269a7b02d2434e5c9ffd859d138baf09520f2c430f6f0ca7

Contents?: true

Size: 305 Bytes

Versions: 9

Compression:

Stored size: 305 Bytes

Contents

class String
  # taken from active-support
  def underscore
    gsub(/::/, '/').
      gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
      gsub(/([a-z\d])([A-Z])/,'\1_\2').
      tr("-", "_").
      downcase
  end

  def camelize
    gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
etest-unit-0.7.4 lib/string_ext.rb
etest-unit-0.7.3 lib/string_ext.rb
etest-unit-0.7.2 lib/string_ext.rb
etest-unit-0.7.1 lib/string_ext.rb
etest-unit-0.7.0 lib/string_ext.rb
etest-0.6.3 lib/string_ext.rb
etest-0.6.2 lib/string_ext.rb
etest-0.6.1 lib/string_ext.rb
etest-0.6.0 lib/string_ext.rb