class String

Public Instance Methods

remove(string_or_rx) click to toggle source
# File lib/hobo_support/string.rb, line 3
def remove(string_or_rx)
  sub(string_or_rx, '')
end
remove!(string_or_rx) click to toggle source
# File lib/hobo_support/string.rb, line 7
def remove!(string_or_rx)
  sub!(string_or_rx, '')
end
remove_all(string_or_rx) click to toggle source
# File lib/hobo_support/string.rb, line 11
def remove_all(string_or_rx)
  gsub(string_or_rx, '')
end
remove_all!(string_or_rx) click to toggle source
# File lib/hobo_support/string.rb, line 15
def remove_all!(string_or_rx)
  gsub!(string_or_rx, '')
end
safe_constantize() click to toggle source

Return the constant that this string refers to, or nil if ActiveSupport cannot load such a constant. This is much safer than `rescue NameError`, as that will mask genuine NameErrors that have been made in the code being loaded (safe_constantize will not)

# File lib/hobo_support/string.rb, line 22
def safe_constantize
  Object.class_eval self
rescue NameError => e
  if e.missing_name != self
    # oops - some other name error
    raise
  else
    nil
  end
end