require 'nokogiri' module AttachmentToHTML module Adapters # Convert text/plain documents in to HTML class Text attr_reader :attachment, :wrapper # Public: Initialize a Text converter # # attachment - the FoiAttachment to convert to HTML # opts - a Hash of options (default: {}): # :wrapper - String id of the div that wraps the # attachment body def initialize(attachment, opts = {}) @attachment = attachment @wrapper = opts.fetch(:wrapper, 'wrapper') end # Public: Convert the attachment to HTML # # Returns a String def to_html @html ||= generate_html end # Public: Was the document conversion successful? # # Returns a Boolean def success? has_content? || contains_images? end private def generate_html html = "" html += "" html += "
" html += "