Module: Mycrm::CoreExt::String

Defined in:
lib/mycrm/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#to_addressObject



19
20
21
# File 'lib/mycrm/core_ext/string.rb', line 19

def to_address
  Mycrm::CoreExt::Address.new(self)
end

#to_camelizedObject



14
15
16
17
# File 'lib/mycrm/core_ext/string.rb', line 14

def to_camelized
  return self if self.to_s !~ /_/ && self.to_s =~ /[A-Z]+.*/
  self.to_s.split('_').collect(&:capitalize).join
end

#to_underscoreObject



6
7
8
9
10
11
12
# File 'lib/mycrm/core_ext/string.rb', line 6

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