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



24
25
26
# File 'lib/restfulx/configuration.rb', line 24

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



19
20
21
# File 'lib/restfulx/configuration.rb', line 19

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