Class: PdfMatcher::PdfFile::Tempfile
- Defined in:
- lib/pdf_matcher/pdf_file.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(data) ⇒ Tempfile
constructor
A new instance of Tempfile.
- #open ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(data) ⇒ Tempfile
Returns a new instance of Tempfile.
48 49 50 51 |
# File 'lib/pdf_matcher/pdf_file.rb', line 48 def initialize(data) super(data: data, path: nil) @io = nil end |
Instance Method Details
#close ⇒ Object
66 67 68 69 |
# File 'lib/pdf_matcher/pdf_file.rb', line 66 def close @io&.close! @io = nil end |
#open ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/pdf_matcher/pdf_file.rb', line 53 def open @io ||= ::Tempfile.open do |f| f.binmode f.puts data f end end |
#path ⇒ Object
61 62 63 64 |
# File 'lib/pdf_matcher/pdf_file.rb', line 61 def path path = @io&.path path ? Pathname(path) : nil end |