Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/eveapi/util.rb
Overview
Utility String methods
Instance Method Summary collapse
- #camelize ⇒ Object
-
#underscore ⇒ Object
Stolen from ActiveSupport::Inflector.
Instance Method Details
#camelize ⇒ Object
32 33 34 |
# File 'lib/eveapi/util.rb', line 32 def camelize split('_').each(&:capitalize!).join('') end |
#underscore ⇒ Object
Stolen from ActiveSupport::Inflector
37 38 39 40 41 42 43 44 45 |
# File 'lib/eveapi/util.rb', line 37 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 |