Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/plus4u_codebase/case_conversions.rb
Overview
Case converter hacks
Instance Method Summary collapse
Instance Method Details
#to_camel_case_lower ⇒ Object
12 13 14 |
# File 'lib/plus4u_codebase/case_conversions.rb', line 12 def to_camel_case_lower self.split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join end |
#to_underscore ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/plus4u_codebase/case_conversions.rb', line 4 def to_underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2'). gsub(/([a-z\d])([A-Z])/, '\1_\2'). tr("-", "_"). downcase end |