Class: TempfileFor::Tempfile
- Defined in:
- lib/tempfile_for/tempfile.rb
Instance Method Summary collapse
Methods inherited from Tempfile
Instance Method Details
#copy(options = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/tempfile_for/tempfile.rb', line 6 def copy( = {}) encoding = [:encoding] tempfile = self.class.open("tempfile", :encoding => encoding) File.open path, :encoding => encoding do |stream| tempfile.write_ext stream end tempfile.rewind tempfile end |
#write_ext(io_or_data) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/tempfile_for/tempfile.rb', line 19 def write_ext(io_or_data) if io_or_data.respond_to?(:read) write(io_or_data.read(1024)) until io_or_data.eof? else write io_or_data end end |