Sha256: 48a518d61f20e92c463ece0347b1662e4494a130e20803fe4a079190006386ac
Contents?: true
Size: 397 Bytes
Versions: 6
Compression:
Stored size: 397 Bytes
Contents
# frozen_string_literal: true # Stolen from Active Support and changed a bit # may in the future be substituted by facets version class String def underscore return self unless /[A-Z-]|::/.match?(self) word = to_s.gsub('::', '/') 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
Version data entries
6 entries across 6 versions & 1 rubygems