Module: Animoto::Support::String
- Defined in:
- lib/animoto/support/string.rb
Instance Method Summary collapse
-
#camelize ⇒ String
Transforms this string from underscore-form to camel case.
-
#underscore ⇒ String
Transforms this string from camel case to underscore-form.
Instance Method Details
#camelize ⇒ String
Transforms this string from underscore-form to camel case. Capitalizes the first letter.
12 13 14 |
# File 'lib/animoto/support/string.rb', line 12 def camelize self.gsub(/(?:^|_)(.)/) { $1.upcase } end |
#underscore ⇒ String
Transforms this string from camel case to underscore-form. Downcases the entire string.
23 24 25 |
# File 'lib/animoto/support/string.rb', line 23 def underscore self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').gsub(/([a-z\d])([A-Z])/,'\1_\2').downcase end |