module Thor::Util
def self.snake_case(str)
String
==== Returns
String
==== Parameters
Receives a string and convert it to snake case. SnakeCase returns snake_case.
def self.snake_case(str) return str.downcase if str =~ /^[A-Z_]+$/ str.gsub(/\B[A-Z]/, '_\&').squeeze('_') =~ /_*(.*)/ return $+.downcase end