Class: String

Inherits:
Object show all
Defined in:
lib/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#classifyObject



3
4
5
# File 'lib/core_ext/string.rb', line 3

def classify
  self.underscore.split(/_/).each { |word| word.capitalize! }.join('')
end

#reverse_classifyObject



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

#underscoreObject



7
8
9
# File 'lib/core_ext/string.rb', line 7

def underscore
  self.gsub(/-|\s+/, '_')
end