Class: Postdoc::HTMLDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/postdoc/html_document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, path: nil) ⇒ HTMLDocument

Returns a new instance of HTMLDocument.



11
12
13
14
15
16
17
# File 'lib/postdoc/html_document.rb', line 11

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

  file.write content
  file.flush
end

Instance Attribute Details

#fileObject

Returns the value of attribute file.



7
8
9
# File 'lib/postdoc/html_document.rb', line 7

def file
  @file
end

Instance Method Details

#cleanupObject



19
20
21
22
# File 'lib/postdoc/html_document.rb', line 19

def cleanup
  file.close
  file.unlink
end