Class: String

Inherits:
Object show all
Defined in:
lib/rui/utils.rb

Instance Method Summary collapse

Instance Method Details

#camelizeObject

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

#underscoreObject

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