Class: Postdoc::HTMLDocument
- Inherits:
-
Object
- Object
- Postdoc::HTMLDocument
- Defined in:
- lib/postdoc/html_document.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(content, path: nil) ⇒ HTMLDocument
constructor
A new instance of HTMLDocument.
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
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/postdoc/html_document.rb', line 7 def file @file end |
Instance Method Details
#cleanup ⇒ Object
19 20 21 22 |
# File 'lib/postdoc/html_document.rb', line 19 def cleanup file.close file.unlink end |