Sha256: 238ee2b38a2e2bafff041b4722d1e352c8662ee42d13eb7a2bd1c557f7d3967e
Contents?: true
Size: 474 Bytes
Versions: 40
Compression:
Stored size: 474 Bytes
Contents
module Underscorable # Port from activesupport-4.2.7.1/lib/active_support/inflector/methods.rb def underscore return self unless self =~ /[A-Z-]|::/ word = self.to_s.gsub(/::/, '/') word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)((?=a)b)(?=\b|[^a-z])/) { "#{$1 && '_'}#{$2.downcase}" } word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2') word.gsub!(/([a-z\d])([A-Z])/,'\1_\2') word.tr!("-", "_") word.downcase! word end end String.include Underscorable
Version data entries
40 entries across 40 versions & 1 rubygems