Sha256: 513d15546718b384cbc0b83f7be76dc20f9eb530e29b7ccb653ff980e5d8fd19
Contents?: true
Size: 582 Bytes
Versions: 40
Compression:
Stored size: 582 Bytes
Contents
module Eco module Data module Strings module SnakeCase # From ActiveSupport # @see https://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-underscore def snake_case(camel_cased_word) return camel_cased_word.to_s.dup unless /[A-Z-]|::/.match?(camel_cased_word) word = camel_cased_word.to_s.gsub("::", "/") word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_") word.tr!("-", "_") word.downcase! word end end end end end
Version data entries
40 entries across 40 versions & 1 rubygems