lib/extensions/string.rb in taza-0.8.7 vs lib/extensions/string.rb in taza-0.9.0
- old
+ new
@@ -1,11 +1,22 @@
-require 'rubygems'
-require 'activesupport'
class String
# pluralizes a string and turns it into a symbol
# Example:
# "apple".pluralize_to_sym # => :apples
def pluralize_to_sym
self.pluralize.to_sym
+ end
+
+ # takes human readable words and
+ # turns it into ruby variable format
+ # dash and spaces to underscore
+ # and lowercases
+ def variablize
+ self.squeeze!(' ')
+ self.gsub!(/\s+/,'_')
+ self.gsub!('-', '_')
+ self.squeeze!('_')
+ self.downcase!
+ self
end
end
\ No newline at end of file