Module: Goodreads::StringExtensions

Defined in:
lib/goodreads/string_extensions.rb

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Strips out whitespace then tests if the string is empty.

Returns:

  • (Boolean)


26
27
28
# File 'lib/goodreads/string_extensions.rb', line 26

def blank?
  strip.empty?
end

#goodreads_strip_bad_description_contentObject



21
22
23
# File 'lib/goodreads/string_extensions.rb', line 21

def goodreads_strip_bad_description_content
  gsub(/^\([^\)]+\)/, '').gsub(/more$/, '')
end

#goodreads_strip_tagsObject

Strip tags



17
18
19
# File 'lib/goodreads/string_extensions.rb', line 17

def goodreads_strip_tags
  gsub(/<\/?[^>]*>/, "")
end

#goodreads_unescape_htmlObject

Unescape HTML



7
8
9
10
11
12
13
14
# File 'lib/goodreads/string_extensions.rb', line 7

def goodreads_unescape_html
  if String.method_defined?(:encode)
    CGI::unescapeHTML(self.encode("UTF-8", 'ISO-8859-1'))
  else
    require 'iconv'
    Iconv.conv("UTF-8", 'ISO-8859-1', CGI::unescapeHTML(self)) 
  end
end