Module: RubyFeatures::Utils::Inflector
- Defined in:
- lib/ruby-features/utils/inflector.rb
Instance Method Summary collapse
Instance Method Details
#camelize(string) ⇒ Object
5 6 7 |
# File 'lib/ruby-features/utils/inflector.rb', line 5 def camelize(string) string.gsub(/([a-z\d]+)/i) { $1.capitalize }.gsub(/[-_]/, '').gsub('/', '::') end |
#underscore(string) ⇒ Object
9 10 11 12 13 |
# File 'lib/ruby-features/utils/inflector.rb', line 9 def underscore(string) string.gsub(/([A-Z][a-z\d]*)/){ "_#{$1.downcase}" }. gsub(/^_/, ''). gsub('::', '/') end |