Class: String

Inherits:
Object show all
Defined in:
lib/crack/core_extensions.rb

Overview

class FalseClass

Instance Method Summary collapse

Instance Method Details

#snake_caseObject



60
61
62
63
64
# File 'lib/crack/core_extensions.rb', line 60

def snake_case
  return self.downcase if self =~ /^[A-Z]+$/
  self.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
  return $+.downcase
end