Class: Puma::NullIO
- Inherits:
-
Object
- Object
- Puma::NullIO
- 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 Method Summary collapse
- #binmode ⇒ Object
- #binmode? ⇒ Boolean
- #close ⇒ Object
-
#closed? ⇒ Boolean
This is used as singleton class, so can’t have state.
- #each ⇒ Object
- #eof? ⇒ Boolean
-
#external_encoding ⇒ Object
per rack spec.
- #flush ⇒ Object
- #gets ⇒ Object
- #pos ⇒ Object
- #puts(*ary) ⇒ Object
-
#read(length = nil, buffer = nil) ⇒ Object
Mimics IO#read with no data.
- #rewind ⇒ Object
- #seek(pos, whence = 0) ⇒ Object
- #set_encoding(enc) ⇒ Object
- #size ⇒ Object
- #string ⇒ Object
- #sync ⇒ Object
- #sync=(v) ⇒ Object
- #write(*ary) ⇒ Object
Instance Method Details
#binmode ⇒ Object
93 94 95 |
# File 'lib/puma/null_io.rb', line 93 def binmode self end |
#binmode? ⇒ Boolean
97 98 99 |
# File 'lib/puma/null_io.rb', line 97 def binmode? true end |
#close ⇒ Object
51 52 |
# File 'lib/puma/null_io.rb', line 51 def close end |
#closed? ⇒ Boolean
This is used as singleton class, so can’t have state.
80 81 82 |
# File 'lib/puma/null_io.rb', line 80 def closed? false end |
#each ⇒ Object
16 17 |
# File 'lib/puma/null_io.rb', line 16 def each end |
#eof? ⇒ Boolean
58 59 60 |
# File 'lib/puma/null_io.rb', line 58 def eof? true end |
#external_encoding ⇒ Object
per rack spec
89 90 91 |
# File 'lib/puma/null_io.rb', line 89 def external_encoding Encoding::ASCII_8BIT end |
#flush ⇒ Object
75 76 77 |
# File 'lib/puma/null_io.rb', line 75 def flush self end |
#gets ⇒ Object
8 9 10 |
# File 'lib/puma/null_io.rb', line 8 def gets nil end |
#pos ⇒ Object
19 20 21 |
# File 'lib/puma/null_io.rb', line 19 def pos 0 end |
#puts(*ary) ⇒ Object
69 70 |
# File 'lib/puma/null_io.rb', line 69 def puts(*ary) end |
#read(length = nil, buffer = nil) ⇒ Object
Mimics IO#read with no data.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# 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 ⇒ Object
43 44 |
# File 'lib/puma/null_io.rb', line 43 def rewind end |
#seek(pos, whence = 0) ⇒ Object
46 47 48 49 |
# 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) ⇒ Object
84 85 86 |
# File 'lib/puma/null_io.rb', line 84 def set_encoding(enc) self end |
#size ⇒ Object
54 55 56 |
# File 'lib/puma/null_io.rb', line 54 def size 0 end |
#string ⇒ Object
12 13 14 |
# File 'lib/puma/null_io.rb', line 12 def string "" end |
#sync ⇒ Object
62 63 64 |
# File 'lib/puma/null_io.rb', line 62 def sync true end |
#sync=(v) ⇒ Object
66 67 |
# File 'lib/puma/null_io.rb', line 66 def sync=(v) end |
#write(*ary) ⇒ Object
72 73 |
# File 'lib/puma/null_io.rb', line 72 def write(*ary) end |