Class: String
Instance Method Summary collapse
- #camelize ⇒ Object
- #classify ⇒ Object
- #constantize ⇒ Object
- #humanize ⇒ Object
-
#pluralize ⇒ Object
poor man’s…
- #underscore ⇒ Object
Instance Method Details
#camelize ⇒ Object
256 257 258 259 260 261 262 |
# File 'lib/helpers.rb', line 256 def camelize if self =~ %r{_} split( '_' ).collect( &:capitalize ).join( '' ) else capitalize end end |
#classify ⇒ Object
264 265 266 267 268 269 270 |
# File 'lib/helpers.rb', line 264 def classify if self =~ %r{/} split( '/' ).collect( &:camelize ).join( '::' ) else camelize end end |
#constantize ⇒ Object
272 273 274 |
# File 'lib/helpers.rb', line 272 def constantize eval( classify ) end |
#humanize ⇒ Object
280 281 282 |
# File 'lib/helpers.rb', line 280 def humanize split( '_' ).collect( &:capitalize ).join( ' ' ) end |
#pluralize ⇒ Object
poor man’s…
285 286 287 |
# File 'lib/helpers.rb', line 285 def pluralize "#{self}s" end |
#underscore ⇒ Object
276 277 278 |
# File 'lib/helpers.rb', line 276 def underscore gsub(/([a-zA-Z])([A-Z])/, '\1_\2').downcase end |