Module: TempFileMethods
- Included in:
- ImageRuby::DevilFileLoader, ImageRuby::DevilPersistor, ImageRuby::ImageRubyDevilMixin, ImageRuby::ImageRubyDevilMixin
- Defined in:
- lib/helper/tempfile.rb
Instance Method Summary collapse
- #create_temp_file(basename, data) ⇒ Object
- #create_temp_path(basename) ⇒ Object
- #use_temp_file(path) ⇒ Object
Instance Method Details
#create_temp_file(basename, data) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/helper/tempfile.rb', line 25 def create_temp_file(basename, data) tmpfile = Tempfile.new(basename) ret = nil begin tmpfile.write data tmpfile.close ret = yield(tmpfile) ensure tmpfile.delete end ret end |
#create_temp_path(basename) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/helper/tempfile.rb', line 47 def create_temp_path(basename) tmpfile = Tempfile.new(basename) tmppath = tmpfile.path tmpfile.close tmpfile.delete tmppath end |
#use_temp_file(path) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/helper/tempfile.rb', line 39 def use_temp_file(path) begin yield ensure File.delete(path) end end |