Class: String

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

Instance Method Summary collapse

Instance Method Details

#pluralize_to_symObject

pluralizes a string and turns it into a symbol Example:

"apple".pluralize_to_sym    # => :apples


6
7
8
# File 'lib/extensions/string.rb', line 6

def pluralize_to_sym
  self.pluralize.to_sym
end

#variablizeObject

takes human readable words and turns it into ruby variable format dash and spaces to underscore and lowercases



14
15
16
17
18
19
20
21
# File 'lib/extensions/string.rb', line 14

def variablize
  self.squeeze!(' ')
	self.gsub!(/\s+/,'_')
	self.gsub!('-', '_')
	self.squeeze!('_')
	self.downcase!
	self
end