Class: Bulldog::Stream::ForIO
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#content_type, #file_name, #initialize, #missing?, #reload, #size
Constructor Details
This class inherits a constructor from Bulldog::Stream::Base
Instance Method Details
#path ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/bulldog/stream.rb', line 147 def path return @path if @path # Keep extension if it's available. Some commands may use the # file extension of the input file, for example. tempfile_name = 'bulldog' if @target.respond_to?(:original_path) && @target.original_path tempfile_name = [tempfile_name, File.extname(@target.original_path)] end Tempfile.open(tempfile_name) do |file| write_to_io(file) @path = file.path # Don't let the tempfile be GC'd until the stream is, as the # tempfile's finalizer deletes the file. @tempfile = file end @path end |
#write_to(path) ⇒ Object
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/bulldog/stream.rb', line 166 def write_to(path) if @path super else open(path, 'w') do |file| write_to_io(file) @path = file.path end end end |