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

Version Path
coltrane-1.0.26 lib/core_ext.rb
coltrane-1.0.24 lib/core_ext.rb
coltrane-1.0.22 lib/core_ext.rb
coltrane-1.0.21 lib/core_ext.rb
coltrane-1.0.20 lib/core_ext.rb
coltrane-1.0.2 lib/core_ext.rb