Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/zimbra_rest_api/utils.rb

Instance Method Summary collapse

Instance Method Details

#camelize(first_letter_in_uppercase = true) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/zimbra_rest_api/utils.rb', line 3

def camelize(first_letter_in_uppercase = true)
  if first_letter_in_uppercase
    self.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
  else
    self[0] + camelize(self)[1..-1]
  end
end

#constantizeObject



11
12
13
# File 'lib/zimbra_rest_api/utils.rb', line 11

def constantize
  Object.const_get self
end

#pluralObject



15
16
17
18
# File 'lib/zimbra_rest_api/utils.rb', line 15

def plural
  return self if self.downcase == 'cos'
  self.to_s + 's'
end