Module: JMX::StringUtils
- Defined in:
- lib/jmx/util/string_utils.rb
Instance Method Summary collapse
Instance Method Details
#camelcase(string) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/jmx/util/string_utils.rb', line 7 def camelcase(string) if string =~ /_/ string.to_s.gsub(/(?:^|_)(.)/) { $1.upcase } else string.to_s end end |
#snakecase(string) ⇒ Object
3 4 5 |
# File 'lib/jmx/util/string_utils.rb', line 3 def snakecase(string) string.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase end |