Sha256: 6990fd9535be699533af0974ee746cade5abe6ad9c27008c9cbe1fed3f4325ce

Contents?: true

Size: 401 Bytes

Versions: 9

Compression:

Stored size: 401 Bytes

Contents

# frozen_string_literal: true

require 'rails'

module Postdoc
  class HTMLDocument
    attr_accessor :file

    delegate :path, to: :file

    def initialize(content, path: nil)
      path ||= Rails.root&.join('tmp') || '/tmp'
      @file = Tempfile.new ['input', '.html'], path

      file.write content
      file.flush
    end

    def cleanup
      file.close
      file.unlink
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
postdoc-0.5.0 lib/postdoc/html_document.rb
postdoc-0.4.5 lib/postdoc/html_document.rb
postdoc-0.4.4 lib/postdoc/html_document.rb
postdoc-0.4.3 lib/postdoc/html_document.rb
postdoc-0.4.2 lib/postdoc/html_document.rb
postdoc-0.4.1 lib/postdoc/html_document.rb
postdoc-0.4.0 lib/postdoc/html_document.rb
postdoc-0.3.9 lib/postdoc/html_document.rb
postdoc-0.3.8 lib/postdoc/html_document.rb