Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/string/underscore.rb

Instance Method Summary collapse

Instance Method Details

#underscoreObject



2
3
4
5
# File 'lib/core_ext/string/underscore.rb', line 2

def underscore
  str = to_s
  str[0, 1].downcase + str[1..-1].gsub(/[A-Z]/) { |c| "_#{c.downcase}" }
end