Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/sharepoint-stringutils.rb,
lib/sharepoint-stringutils.rb,
lib/sharepoint-stringutils.rb

Instance Method Summary collapse

Instance Method Details

#camelizeObject



18
19
20
# File 'lib/sharepoint-stringutils.rb', line 18

def camelize
  self.split("_").each {|s| s.capitalize! }.join("")
end

#pluralizeObject



26
27
28
29
30
31
32
33
34
# File 'lib/sharepoint-stringutils.rb', line 26

def pluralize
  if self.match /y$/
    self.gsub /y$/, 'ies'
  elsif self.match /us$/
    self.gsub /us$/, 'i'
  else
    self + 's'
  end
end

#underscoreObject



6
7
8
9
10
11
12
# File 'lib/sharepoint-stringutils.rb', line 6

def underscore
  self.gsub(/::/, '/').
    gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
    gsub(/([a-z\d])([A-Z])/,'\1_\2').
    tr("-", "_").
    downcase
end