Method: Dhis2::Case.underscore
- Defined in:
- lib/dhis2/case.rb
.underscore(camel_cased_word) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/dhis2/case.rb', line 33 def self.underscore(camel_cased_word) return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/ camel_cased_word.to_s.gsub(/::/, "/") .gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr("-", "_") .downcase end |