Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/xml-fu/core_ext/string.rb

Overview

Redefined parts of the String class to suit our needs in the gem.

Instance Method Summary (collapse)

Instance Method Details

- (Object) camelcase

Returns the string in camelcase (with the first character uppercase)



10
11
12
# File 'lib/xml-fu/core_ext/string.rb', line 10

def camelcase
  self.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
end

- (Object) lower_camelcase

Returns the string in camelcase (with first character lowercase)



5
6
7
# File 'lib/xml-fu/core_ext/string.rb', line 5

def lower_camelcase
  self[0].chr.downcase + self.camelcase[1..-1]
end