Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/generators/entity_def/entity_def_generator.rb

Instance Method Summary collapse

Instance Method Details

#snake_caseObject



5
6
7
8
9
10
# File 'lib/generators/entity_def/entity_def_generator.rb', line 5

def snake_case
  return downcase if match(/\A[A-Z]+\z/)
  gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
  gsub(/([a-z])([A-Z])/, '\1_\2').
  downcase
end