Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/plus4u_codebase/case_conversions.rb

Overview

Case converter hacks

Instance Method Summary collapse

Instance Method Details

#to_camel_case_lowerObject



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_underscoreObject



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