diff options
author | Louise Crow <louise.crow@gmail.com> | 2015-05-21 09:46:18 +0200 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2015-05-21 09:46:18 +0200 |
commit | dd446425107b58ee98dd26c7419e7c09e275a751 (patch) | |
tree | b23cca80ebcf4e33bb774468ca4fbf499e43f7e6 /lib/attachment_to_html/adapters/text.rb | |
parent | da706b6c05ee7d0be15b59cf0fdec7f6d3ed58ec (diff) | |
parent | f2d08c8ece66f8bac867214a65ab1b7f9fe5da92 (diff) |
Merge remote-tracking branch 'jpmckinney_github/extract_method3' into rails-3-develop
Diffstat (limited to 'lib/attachment_to_html/adapters/text.rb')
-rw-r--r-- | lib/attachment_to_html/adapters/text.rb | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/lib/attachment_to_html/adapters/text.rb b/lib/attachment_to_html/adapters/text.rb index 7e22422e2..61e4e57a8 100644 --- a/lib/attachment_to_html/adapters/text.rb +++ b/lib/attachment_to_html/adapters/text.rb @@ -2,33 +2,7 @@ module AttachmentToHTML module Adapters # Convert text/plain documents in to HTML - class Text - - attr_reader :attachment - - # Public: Initialize a Text converter - # - # attachment - the FoiAttachment to convert to HTML - # opts - a Hash of options (default: {}): - # No options currently accepted - def initialize(attachment, opts = {}) - @attachment = attachment - end - - # Public: The title to use in the <title> tag - # - # Returns a String - def title - @title ||= attachment.display_filename - end - - # Public: The contents of the extracted html <body> tag - # - # Returns a String - def body - @body ||= parse_body - end - + class Text < Adapter # Public: Was the document conversion successful? # # Returns a Boolean @@ -44,19 +18,6 @@ module AttachmentToHTML text = MySociety::Format.make_clickable(text) text = text.gsub(/\n/, '<br>') end - - def parse_body - convert - end - - def has_content? - !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty? - end - - def contains_images? - body.match(/<img[^>]*>/mi) ? true : false - end - end end end |