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
255 256 257 258 259 260 261 |
# File 'lib/helpers.rb', line 255 def camelize if self =~ %r{_} split( '_' ).collect( &:capitalize ).join( '' ) else capitalize end end |
#classify ⇒ Object
263 264 265 266 267 268 269 |
# File 'lib/helpers.rb', line 263 def classify if self =~ %r{/} split( '/' ).collect( &:camelize ).join( '::' ) else camelize end end |
#constantize ⇒ Object
271 272 273 |
# File 'lib/helpers.rb', line 271 def constantize eval( classify ) end |
#humanize ⇒ Object
279 280 281 |
# File 'lib/helpers.rb', line 279 def humanize split( '_' ).collect( &:capitalize ).join( ' ' ) end |
#pluralize ⇒ Object
poor man’s…
284 285 286 |
# File 'lib/helpers.rb', line 284 def pluralize "#{self}s" end |
#underscore ⇒ Object
275 276 277 |
# File 'lib/helpers.rb', line 275 def underscore gsub(/([a-zA-Z])([A-Z])/, '\1_\2').downcase end |