Class: String
Instance Method Summary collapse
Instance Method Details
#classify ⇒ Object
3 4 5 |
# File 'lib/core_ext/string.rb', line 3 def classify self.underscore.split(/_/).each { |word| word.capitalize! }.join('') end |
#reverse_classify ⇒ Object
11 12 13 |
# File 'lib/core_ext/string.rb', line 11 def reverse_classify self.gsub(/([A-Z])/, ' \1').strip.split(/ /).each { |word| word.downcase! }.join('_') end |
#underscore ⇒ Object
7 8 9 |
# File 'lib/core_ext/string.rb', line 7 def underscore self.gsub(/-|\s+/, '_') end |