Class: PDFService::Utils::TempfileService
- Inherits:
-
Object
- Object
- PDFService::Utils::TempfileService
- Defined in:
- lib/pdf_service/utils/tempfile_service.rb
Instance Method Summary collapse
-
#initialize(root: Pathname('.')) ⇒ TempfileService
constructor
A new instance of TempfileService.
- #use(name: SecureRandom.hex, extension: 'tmp') ⇒ Object
Constructor Details
#initialize(root: Pathname('.')) ⇒ TempfileService
Returns a new instance of TempfileService.
4 5 6 |
# File 'lib/pdf_service/utils/tempfile_service.rb', line 4 def initialize(root: Pathname('.')) @root = Pathname(root) end |
Instance Method Details
#use(name: SecureRandom.hex, extension: 'tmp') ⇒ Object
8 9 10 11 12 13 |
# File 'lib/pdf_service/utils/tempfile_service.rb', line 8 def use(name: SecureRandom.hex, extension: 'tmp') path = Pathname('.')..join("#{name}.#{extension}") yield(path) ensure path.unlink if path.exist? end |