Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/rosetta_queue/core_ext/string.rb
Overview
Taken from ActiveSupport
Instance Method Summary collapse
Instance Method Details
#camelize(first_letter_in_uppercase = true) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/rosetta_queue/core_ext/string.rb', line 3 def camelize(first_letter_in_uppercase = true) if first_letter_in_uppercase self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } else self.first.downcase + camelize(self)[1..-1] end end |
#classify ⇒ Object
11 12 13 |
# File 'lib/rosetta_queue/core_ext/string.rb', line 11 def classify camelize(self.sub(/.*\./, '')) end |
#underscore ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/rosetta_queue/core_ext/string.rb', line 15 def underscore self.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end |