Sha256: 99c03aff0e3b62f3fe13cac81c45c9f3db0a3e4e5814838f935c8757ac24bd61

Contents?: true

Size: 728 Bytes

Versions: 51

Compression:

Stored size: 728 Bytes

Contents

class String

  def remove(string_or_rx)
    sub(string_or_rx, '')
  end

  def remove!(string_or_rx)
    sub!(string_or_rx, '')
  end

  def remove_all(string_or_rx)
    gsub(string_or_rx, '')
  end

  def remove_all!(string_or_rx)
    gsub!(string_or_rx, '')
  end

  # 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)
  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


end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
hobo_support-2.2.6 lib/hobo_support/string.rb
hobo_support-2.2.5 lib/hobo_support/string.rb
hobo_support-2.2.4 lib/hobo_support/string.rb
hobo_support-2.2.3 lib/hobo_support/string.rb
hobo_support-2.2.2 lib/hobo_support/string.rb
hobo_support-2.2.1 lib/hobo_support/string.rb
hobo_support-2.2.0 lib/hobo_support/string.rb
hobo_support-2.1.2 lib/hobo_support/string.rb
hobo_support-2.1.1 lib/hobo_support/string.rb
hobo_support-2.1.0 lib/hobo_support/string.rb
hobo_support-2.1.0.pre4 lib/hobo_support/string.rb
hobo_support-2.1.0.pre3 lib/hobo_support/string.rb
hobo_support-2.1.0.pre2 lib/hobo_support/string.rb
hobo_support-2.1.0.pre1 lib/hobo_support/string.rb
hobo_support-2.0.1 lib/hobo_support/string.rb
hobo_support-2.0.0 lib/hobo_support/string.rb
hobo_support-2.0.0.pre10 lib/hobo_support/string.rb
hobo_support-2.0.0.pre9 lib/hobo_support/string.rb
hobo_support-2.0.0.pre8 lib/hobo_support/string.rb
hobo_support-1.3.3 lib/hobo_support/string.rb