Sha256: e25ace9f4f0d80069a10169c076a91f3ecc189777104741e7114e0a231e82396

Contents?: true

Size: 335 Bytes

Versions: 4

Compression:

Stored size: 335 Bytes

Contents

module Finnegans
  module Support
    class << self
      def snakecase(string)
        str = string.dup
        str.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
        str.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
        str.tr!('-', '_')
        str.gsub!(/\s/, '_')
        str.gsub!(/__+/, '_')
        str.downcase
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
finnegans-0.1.4 lib/finnegans/support.rb
finnegans-0.1.3 lib/finnegans/support.rb
finnegans-0.1.2 lib/finnegans/support.rb
finnegans-0.1.1 lib/finnegans/support.rb