Module: Tins::StringCamelize
- Defined in:
- lib/tins/string_camelize.rb
Instance Method Summary collapse
- #camelize(first_letter = :upper) ⇒ Object (also: #camelcase)
Instance Method Details
#camelize(first_letter = :upper) ⇒ Object Also known as: camelcase
3 4 5 6 7 8 9 10 |
# File 'lib/tins/string_camelize.rb', line 3 def camelize(first_letter = :upper) case first_letter when :upper, true gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } when :lower, false self[0].chr.downcase + camelize[1..-1] end end |