Class: Bulldog::Stream::ForTempfile

Inherits:
Base
  • Object
show all
Defined in:
lib/bulldog/stream.rb

Instance Attribute Summary

Attributes inherited from Base

#target

Instance Method Summary collapse

Methods inherited from Base

#content_type, #file_name, #missing?, #reload, #write_to

Constructor Details

#initialize(target) ⇒ ForTempfile

Returns a new instance of ForTempfile.



101
102
103
104
105
# File 'lib/bulldog/stream.rb', line 101

def initialize(target)
  super
  @path = target.path or
    raise ArgumentError, "Tempfile is closed - cannot retrieve information"
end

Instance Method Details

#pathObject



107
108
109
110
# File 'lib/bulldog/stream.rb', line 107

def path
  @target.flush unless @target.closed?
  super
end

#sizeObject



112
113
114
115
116
# File 'lib/bulldog/stream.rb', line 112

def size
  # Tempfile#size returns nil when closed.
  @target.flush unless @target.closed?
  File.size(@target.path)
end