123456789_123456789_123456789_123456789_123456789_

Class: Puma::NullIO

Relationships & Source Files
Inherits: Object
Defined in: lib/puma/null_io.rb

Overview

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.

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#binmode (readonly)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 93

def binmode
  self
end

#binmode?Boolean (readonly)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 97

def binmode?
  true
end

#closed?Boolean (readonly)

This is used as singleton class, so can’t have state.

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 80

def closed?
  false
end

#eof?Boolean (readonly)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 58

def eof?
  true
end

#sync (rw)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 62

def sync
  true
end

#sync=(v) (rw)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 66

def sync=(v)
end

Instance Method Details

#close

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 51

def close
end

#each

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 16

def each
end

#external_encoding

per rack spec

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 89

def external_encoding
  Encoding::ASCII_8BIT
end

#flush

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 75

def flush
  self
end

#gets

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 8

def gets
  nil
end

#pos

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 19

def pos
  0
end

#puts(*ary)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 69

def puts(*ary)
end

#read(length = nil, buffer = nil)

Mimics IO#read with no data.

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 25

def read(length = nil, buffer = nil)
  if length.to_i < 0
    raise ArgumentError, "(negative length #{length} given)"
  end

  buffer = if buffer.nil?
    "".b
  else
    String.try_convert(buffer) or raise TypeError, "no implicit conversion of #{buffer.class} into String"
  end
  buffer.clear
  if length.to_i > 0
    nil
  else
    buffer
  end
end

#rewind

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 43

def rewind
end

#seek(pos, whence = 0)

Raises:

  • (ArgumentError)
[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 46

def seek(pos, whence = 0)
  raise ArgumentError, "negative length #{pos} given" if pos.negative?
  0
end

#set_encoding(enc)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 84

def set_encoding(enc)
  self
end

#size

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 54

def size
  0
end

#string

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 12

def string
  ""
end

#write(*ary)

[ GitHub ]

  
# File 'lib/puma/null_io.rb', line 72

def write(*ary)
end