Sha256: a6053003d9f23a93549c41e7faf09ccd9d7a46eed9ce3f6d182cc503306c0756

Contents?: true

Size: 420 Bytes

Versions: 3

Compression:

Stored size: 420 Bytes

Contents

require 'rainbow'

class String
  def pluralize(n, suffix = 's', singular_suffix = '')
    if n == 1
      self + singular_suffix
    else
      self + suffix
    end
  end

  def highlight(pattern)
    gsub(/#{pattern}/i) { |m| Rainbow(m).red }
  end

  def unescape_html
    gsub(/&gt;/, '>').gsub(/&lt;/, '<').gsub(/&amp;/, '&')
  end

  def prefix_subreddit
    return self if length == 0
    '/r/' + self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
usaidwat-1.6.1 lib/usaidwat/ext/string.rb
usaidwat-1.6.0 lib/usaidwat/ext/string.rb
usaidwat-1.5.1 lib/usaidwat/ext/string.rb