Sha256: a774dfc355e148777994bc33361dc0b9b9860cfd9a9ed53deecf328022d89940

Contents?: true

Size: 201 Bytes

Versions: 2

Compression:

Stored size: 201 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 & 1 rubygems

Version Path
fozzie-1.1.0 lib/core_ext/string/snakecase.rb
fozzie-1.0.3 lib/core_ext/string/snakecase.rb