27 lines
		
	
	
		
			384 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			384 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| class String
 | |
|   def present?
 | |
|     !empty?
 | |
|   end
 | |
| 
 | |
|   def blank?
 | |
|     empty?
 | |
|   end
 | |
| 
 | |
|   # from ActiveSupport
 | |
|   def underscore
 | |
|     gsub(/::/, '/').
 | |
|     gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
 | |
|     gsub(/([a-z\d])([A-Z])/,'\1_\2').
 | |
|     tr("-", "_").
 | |
|     downcase
 | |
|   end
 | |
| 
 | |
|   def underscore_class
 | |
|     split('::').last.underscore
 | |
|   end
 | |
| 
 | |
|   # rough simplification
 | |
|   def pluralize
 | |
|     "#{self}s"
 | |
|   end
 | |
| end | 
