Class: String
- Inherits:
-
Object
- Object
- String
- 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
-
#camelcase ⇒ Object
Returns the string in camelcase (with the first character uppercase).
-
#lower_camelcase ⇒ Object
Returns the string in camelcase (with first character lowercase).
Instance Method Details
#camelcase ⇒ Object
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 |
#lower_camelcase ⇒ Object
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 |