Method: Moon::Utility::String.underscore
- Defined in:
- lib/moon/utility/string.rb
.underscore(camel_cased_word) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/moon/utility/string.rb', line 8 def self.underscore(camel_cased_word) camel_cased_word.to_s. gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end |