Method: Thor::Util.snake_case
- Defined in:
- lib/thor/util.rb
permalink .snake_case(str) ⇒ Object
Receives a string and convert it to snake case. SnakeCase returns snake_case.
Parameters
String
Returns
String
90 91 92 93 94 |
# File 'lib/thor/util.rb', line 90 def snake_case(str) return str.downcase if str =~ /^[A-Z_]+$/ str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/ Regexp.last_match(-1).downcase end |