Sha256: c278904b5059fa3bb4b4fdf5b4a4cd82f931b11db2c6117e098b1354af8e9a30

Contents?: true

Size: 683 Bytes

Versions: 28

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

module Puma
  # Provides an IO-like object that always appears to contain no data.
  # Used as the value for rack.input when the request has no body.
  #
  class NullIO
    def gets
      nil
    end

    def string
      ""
    end

    def each
    end

    # Mimics IO#read with no data.
    #
    def read(count = nil, _buffer = nil)
      count && count > 0 ? nil : ""
    end

    def rewind
    end

    def close
    end

    def size
      0
    end

    def eof?
      true
    end

    def sync
      true
    end

    def sync=(v)
    end

    def puts(*ary)
    end

    def write(*ary)
    end

    def flush
      self
    end
  end
end

Version data entries

28 entries across 28 versions & 4 rubygems

Version Path
puma-5.3.2-java lib/puma/null_io.rb
puma-5.3.2 lib/puma/null_io.rb
puma-5.3.1-java lib/puma/null_io.rb
puma-5.3.1 lib/puma/null_io.rb
puma-5.3.0-java lib/puma/null_io.rb
puma-5.3.0 lib/puma/null_io.rb
puma-5.2.2-java lib/puma/null_io.rb
puma-5.2.2 lib/puma/null_io.rb