Sha256: b8a48ba3162cf0a3281002c22938eaac1da3538f24eb1c734bc5b8c0e460891f

Contents?: true

Size: 413 Bytes

Versions: 5

Compression:

Stored size: 413 Bytes

Contents

# frozen_string_literal: true

require 'rails'

module Postdoc
  class HTMLDocument
    attr_accessor :file

    delegate :path, to: :file

    def initialize(content, path: nil, **_options)
      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

5 entries across 5 versions & 1 rubygems

Version Path
postdoc-0.3.7 lib/postdoc/html_document.rb
postdoc-0.3.6 lib/postdoc/html_document.rb
postdoc-0.3.5 lib/postdoc/html_document.rb
postdoc-0.3.4 lib/postdoc/html_document.rb
postdoc-0.3.3 lib/postdoc/html_document.rb