class String

Public Instance Methods

camelcase() click to toggle source
# File lib/site_hook/string_ext.rb, line 25
def camelcase
  dup.camelcase!
end
camelcase!() click to toggle source
# File lib/site_hook/string_ext.rb, line 22
def camelcase!
  to_s.scan(/\w+/).collect(&:capitalize).join
end
camelize() click to toggle source
# File lib/site_hook/string_ext.rb, line 31
def camelize
  dup.camelize!
end
camelize!() click to toggle source
# File lib/site_hook/string_ext.rb, line 28
def camelize!
  to_s.split(/_|\s+/).collect(&:capitalize).join
end
safe_log_name() click to toggle source
# File lib/site_hook/string_ext.rb, line 34
def safe_log_name
  self.split('::').last.underscore
end
squish() click to toggle source
# File lib/site_hook/string_ext.rb, line 7
def squish
  dup.squish!
end
squish!() click to toggle source
# File lib/site_hook/string_ext.rb, line 2
def squish!
  strip!
  gsub!(/\s+/, ' ')
  self
end
underscore() click to toggle source
# File lib/site_hook/string_ext.rb, line 19
def underscore
  dup.underscore!
end
underscore!() click to toggle source
# File lib/site_hook/string_ext.rb, line 10
def underscore!
  self unless /[A-Z-]|::/.match?(self)
  self.to_s.gsub!("::".freeze, "/".freeze)
  self.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2'.freeze)
  self.gsub!(/([a-z\d])([A-Z])/, '\1_\2'.freeze)
  self.tr!("-".freeze, "_".freeze)
  self.downcase!
  self
end