Sha256: 901ad202ba46516f9d30e27e65c668df9493acc3699662952f04141e6364bacf

Contents?: true

Size: 460 Bytes

Versions: 8

Compression:

Stored size: 460 Bytes

Contents

# Tempfile#size reports size of 0 after the tempfile has been
# closed (without unlinking).  This happens because internal
# @tmpfile is set to nil when the Tempfile is closed.
# Alternatively @tmpname is set to nil when file is unlinked.

if RUBY_VERSION < '1.9'
  class Tempfile
    def size
      if @tmpfile
        @tmpfile.flush
        @tmpfile.stat.size
      elsif @tmpname
        File.size(@tmpname)
      else
        0
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dragonfly-1.1.0 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.12 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.11 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.10 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.9 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.8 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.7 lib/dragonfly/core_ext/tempfile.rb
dragonfly-1.0.6 lib/dragonfly/core_ext/tempfile.rb