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

#closed?Boolean (readonly)

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

[ GitHub ]

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

def closed?
  false
end

#eof?Boolean (readonly)

[ GitHub ]

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

def eof?
  true
end

#sync (rw)

[ GitHub ]

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

def sync
  true
end

#sync=(v) (rw)

[ GitHub ]

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

def sync=(v)
end

Instance Method Details

#close

[ GitHub ]

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

def close
end

#each

[ GitHub ]

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

def each
end

#flush

[ GitHub ]

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

def flush
  self
end

#gets

[ GitHub ]

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

def gets
  nil
end

#puts(*ary)

[ GitHub ]

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

def puts(*ary)
end

#read(length = nil, buffer = nil)

Mimics IO#read with no data.

[ GitHub ]

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

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 39

def rewind
end

#size

[ GitHub ]

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

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 63

def write(*ary)
end