Module: OXML::Utils
- Defined in:
- lib/oxml/utils.rb
Class Method Summary collapse
Class Method Details
.camelize(input) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/oxml/utils.rb', line 15 def camelize(input) input .to_s .gsub(/(?:^|_+)([^_])/) { Regexp.last_match(1).upcase } .tap { |s| s[0] = s[0].downcase } end |
.snakecase(input) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/oxml/utils.rb', line 7 def snakecase(input) input .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |