Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/core_ext/ruby/string/camelize.rb,
lib/core_ext/ruby/string/underscore.rb
Instance Method Summary collapse
Instance Method Details
#camelize ⇒ Object
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 |
#underscore ⇒ Object
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 |