class String

Utility String methods

Public Instance Methods

camelize() click to toggle source

Camelize String

@return [String] Camelized String

# File lib/eveapi/util.rb, line 61
def camelize
  split('_').each(&:capitalize!).join('')
end
underscore() click to toggle source

Snake Case a Camelized String

@return [String] Snake Cased version of the String

# 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