Class: String

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

Instance Method Summary collapse

Instance Method Details

#camelizeObject



2
3
4
# File 'lib/core_ext/ruby/string/camelize.rb', line 2

def camelize
  split(/[^a-z0-9]/i).map { |w| w.capitalize }.join
end

#underscoreObject



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

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