aboutsummaryrefslogtreecommitdiffstats
path: root/lib/attachment_to_html/adapters/rtf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/attachment_to_html/adapters/rtf.rb')
-rw-r--r--lib/attachment_to_html/adapters/rtf.rb50
1 files changed, 3 insertions, 47 deletions
diff --git a/lib/attachment_to_html/adapters/rtf.rb b/lib/attachment_to_html/adapters/rtf.rb
index 90478d9ca..4a08bf618 100644
--- a/lib/attachment_to_html/adapters/rtf.rb
+++ b/lib/attachment_to_html/adapters/rtf.rb
@@ -2,9 +2,9 @@
module AttachmentToHTML
module Adapters
# Convert application/rtf documents in to HTML
- class RTF
+ class RTF < Adapter
- attr_reader :attachment, :tmpdir
+ attr_reader :tmpdir
# Public: Initialize a RTF converter
#
@@ -13,24 +13,10 @@ module AttachmentToHTML
# :tmpdir - String name of directory to store the
# converted document
def initialize(attachment, opts = {})
- @attachment = attachment
+ super
@tmpdir = opts.fetch(:tmpdir, ::Rails.root.join('tmp'))
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
-
# Public: Was the document conversion successful?
#
# Returns a Boolean
@@ -45,14 +31,6 @@ module AttachmentToHTML
match ? match[1] : ''
end
- def has_content?
- !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty?
- end
-
- def contains_images?
- body.match(/<img[^>]*>/mi) ? true : false
- end
-
def convert
# Get the attachment body outside of the chdir call as getting
# the body may require opening files too
@@ -83,28 +61,6 @@ module AttachmentToHTML
end
html
end
-
- def create_tempfile(text)
- tempfile = if RUBY_VERSION.to_f >= 1.9
- Tempfile.new('foiextract', '.',
- :encoding => text.encoding)
- else
- Tempfile.new('foiextract', '.')
- end
- tempfile.print(text)
- tempfile.flush
- tempfile
- end
-
- def cleanup_tempfile(tempfile)
- tempfile.close
- tempfile.delete
- end
-
- def attachment_body
- @attachment_body ||= attachment.body
- end
-
end
end
end