Class: String
Instance Method Summary collapse
-
#camelize ⇒ Object
Convert from underscore-separated to camel case.
-
#underscore ⇒ Object
Convert from camel case to underscore_separated.
Instance Method Details
#camelize ⇒ Object
Convert from underscore-separated to camel case.
Example: connect_to_server => connectToServer
39 40 41 |
# File 'lib/rui/utils.rb', line 39 def camelize gsub(/_(.)/) {|m| $1.upcase } end |
#underscore ⇒ Object
Convert from camel case to underscore_separated.
Examples: connectToServer => connect_to_server POP3ConnectionManager => pop3_connection_manager
28 29 30 31 32 |
# File 'lib/rui/utils.rb', line 28 def underscore self.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). downcase end |