Sha256: dd98024b693070d43543bbc71cd5753c7d27eefe79be881bd20cf696b2f592c1

Contents?: true

Size: 192 Bytes

Versions: 2

Compression:

Stored size: 192 Bytes

Contents

class String
  def snakecase
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr('-', '_').
    gsub(/\s/, '_').
    gsub(/__+/, '_').
    downcase
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
shipping-scale-0.1.0 lib/snakecase_string.rb
fozzie-1.0.2 lib/core_ext/string/snakecase.rb