Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/eveapi/util.rb

Overview

Utility String methods

Instance Method Summary collapse

Instance Method Details

#camelizeObject



32
33
34
# File 'lib/eveapi/util.rb', line 32

def camelize
  split('_').each(&:capitalize!).join('')
end

#underscoreObject

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