Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/syndi/rubyext/string.rb

Overview

This changes the String class in Ruby's standard library to make life easier by aliasing String#uc to String#upcase and String#dc to String#downcase

Instance Method Summary collapse

Instance Method Details

#camelizeObject

Somewhat imperfect camelization (from snake-case strings).



10
11
12
13
14
15
16
17
18
# File 'lib/syndi/rubyext/string.rb', line 10

def camelize
  if self !~ /_/
    capitalize
  else
    words = split /_/
    words.map! { |word| word.capitalize }
    words.join
  end
end