Sha256: 5a0ac7492b5862083a6842d3e9053531645375ce79f4ea7dc393676f9c376460
Contents?: true
Size: 356 Bytes
Versions: 6
Compression:
Stored size: 356 Bytes
Contents
# typed: strict # frozen_string_literal: true class String extend T::Sig sig { returns(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