Class: Octodown::Support::PersistentTempfile

Inherits:
Tempfile
  • Object
show all
Defined in:
lib/octodown/support/persistent_tempfile.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(content, ext) ⇒ Object



9
10
11
12
# File 'lib/octodown/support/persistent_tempfile.rb', line 9

def self.create(content, ext)
  document = new ['octodown', ".#{ext}"]
  document.persistent_write content
end

Instance Method Details

#persistObject



14
15
16
17
# File 'lib/octodown/support/persistent_tempfile.rb', line 14

def persist
  ObjectSpace.undefine_finalizer self
  self
end

#persistent_write(content) ⇒ Object



19
20
21
22
23
# File 'lib/octodown/support/persistent_tempfile.rb', line 19

def persistent_write(content)
  write content
  close
  persist
end