class String

Interestingly enough there’s no way to just upper-case or down-case first letter of a given string. Ruby’s own capitalize actually downcases all the rest of the characters in the string We patch the class to add our own implementation.

Public Instance Methods

dcfirst() click to toggle source

Down-case first character of a string leaving the rest of it intact

# File lib/restfulx/configuration.rb, line 24
def dcfirst
  self[0,1].downcase + self[1..-1]
end
ucfirst() click to toggle source

Upper-case first character of a string leave the rest of the string intact

# File lib/restfulx/configuration.rb, line 19
def ucfirst
  self[0,1].capitalize + self[1..-1]
end