class String

Public Instance Methods

constantize() click to toggle source
# File lib/doublemap_api/core_ext/string.rb, line 18
def constantize
  self.tr_s('- ', '_').split('_').map(&:capitalize).join
end
titleize() click to toggle source
# File lib/doublemap_api/core_ext/string.rb, line 14
def titleize
  self.tr_s('- ', '_').split('_').map(&:capitalize).join(' ')
end
underscore() click to toggle source
# File lib/doublemap_api/core_ext/string.rb, line 2
def underscore
  self.dup.underscore!
end
underscore!() click to toggle source
# File lib/doublemap_api/core_ext/string.rb, line 6
def underscore!
  self.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
  self.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
  self.tr_s!('- ', '_')
  self.downcase!
  self
end