Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/eveapi/util.rb
Overview
Utility String methods
Instance Method Summary collapse
-
#camelize ⇒ String
Camelize
String
. -
#underscore ⇒ String
Snake Case a Camelized
String
.
Instance Method Details
#camelize ⇒ String
Camelize String
61 62 63 |
# File 'lib/eveapi/util.rb', line 61 def camelize split('_').each(&:capitalize!).join('') end |
#underscore ⇒ String
Snake Case a Camelized String
68 69 70 71 72 73 74 75 76 |
# File 'lib/eveapi/util.rb', line 68 def underscore return self unless self =~ /[A-Z-]|::/ word = to_s.gsub(/::/, '/') word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr!('-', '_') word.downcase! word end |