module Underscorable
module to convert camelcase to underscore
Public Instance Methods
to_underscore(name)
click to toggle source
# File lib/clashinator/util/underscore.rb, line 3 def to_underscore(name) modified_word = name.dup modified_word.gsub!(/::/, '/') modified_word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2') modified_word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') modified_word.tr!('-', '_') modified_word.downcase! modified_word end