Sha256: 5e9e4ead38121cf8cb63a097bd447e4410f92766954570865351720736efa724
Contents?: true
Size: 545 Bytes
Versions: 2
Compression:
Stored size: 545 Bytes
Contents
# frozen_string_literal: true module MessagesDictionary module Utils # Utility methods for strings module StringUtils refine String do # Underscore a string such that camelcase, dashes and spaces are # replaced by underscores. 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
messages_dictionary-2.1.0 | lib/messages_dictionary/utils/string_utils.rb |
messages_dictionary-2.0.0 | lib/messages_dictionary/utils/string_utils.rb |