Method: Charta.underscore

Defined in:
lib/charta.rb

.underscore(text) ⇒ Object

Utility methods



127
128
129
130
131
132
133
# File 'lib/charta.rb', line 127

def underscore(text)
  text.gsub(/::/, '/')
      .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
      .gsub(/([a-z\d])([A-Z])/, '\1_\2')
      .tr('-', '_')
      .downcase
end