Method: Vedeu::Common#snake_case
- Defined in:
- lib/vedeu/common.rb
#snake_case(klass) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/vedeu/common.rb', line 121 def snake_case(klass) str = klass.is_a?(Module) ? klass.name : klass str.split(/::/).map do |namespace| *upper, _ = namespace.split(/([A-Z]+)/).reject(&:empty?).map do |chars| chars =~ /\p{Lower}/ ? [chars, '_'] : chars end.flatten upper.map(&:downcase).join end.join('/') end |