Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/restfulx/configuration.rb

Overview

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.

Instance Method Summary collapse

Instance Method Details

#dcfirstObject

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



11
12
13
# File 'lib/restfulx/configuration.rb', line 11

def dcfirst
  self[0,1].downcase + self[1..-1]
end

#ucfirstObject

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



6
7
8
# File 'lib/restfulx/configuration.rb', line 6

def ucfirst
  self[0,1].capitalize + self[1..-1]
end