lib/jkl/text_client.rb in jakal-0.1.95 vs lib/jkl/text_client.rb in jakal-0.1.96

- old
+ new

@@ -1,11 +1,11 @@ module Jkl module Text class << self - def sanitize(text, number = 5) - remove_short_lines(strip_all_tags(remove_script_tags(text)), number) + def sanitize(text, words_on_line = 5) + remove_short_lines(strip_all_tags(remove_script_tags(text)), words_on_line) end alias :clean :sanitize def strip_all_tags(text) text.gsub(/<\/?[^>]*>/, "") @@ -22,15 +22,15 @@ def remove_script_tags(text) text = remove_html_comments(text) text.gsub(/((<[\s\/]*script\b[^>]*>)([^>]*)(<\/script>))/i, "") end - def remove_short_lines(text, number = 5) + def remove_short_lines(text, words_on_line = 5) text = text.gsub(/\s\s/, "\n") str = "" # remove short lines - ususally just navigation text.split("\n").each do |l| - str << l unless l.count(" ") < number + str << l unless l.count(" ") < words_on_line end str end end