conflikt/imdb_celebrity

View on GitHub
lib/imdb_celebrity/string_extensions.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'cgi'
require 'iconv'
 
module ImdbCelebrity 
  module StringExtensions
  
    # Unescape HTML
    def imdb_unescape_html
      Iconv.conv("UTF-8", 'ISO-8859-1', CGI::unescapeHTML(self))
    end
  
    # Strip tags
    def imdb_strip_tags
      gsub(/<\/?[^>]*>/, "")
    end
    
    # Strips out whitespace then tests if the string is empty.
    def blank?
      strip.empty?
    end unless method_defined?(:blank?)
  end
end

String.send :include, ImdbCelebrity::StringExtensions