module Inflections

String inflections copied over from ActiveSupport

Public Instance Methods

underscore(camel_cased_word) click to toggle source

Convert Foo::BarBaz to foo/bar_baz. Copied from ActiveSupport.

# File lib/rubocop/highlands/inflections.rb, line 5
def underscore(camel_cased_word)
  word = camel_cased_word.to_s.dup
  word.gsub!(/::/, '/')
  word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
  word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
  word.tr!("-", "_")
  word.downcase!
  word
end