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
- #close ⇒ Object
-
#closed? ⇒ Boolean
This is used as singleton class, so can’t have state.
- #each ⇒ Object
- #eof? ⇒ Boolean
- #flush ⇒ Object
- #gets ⇒ Object
- #puts(*ary) ⇒ Object
-
#read(length = nil, buffer = nil) ⇒ Object
Mimics IO#read with no data.
- #rewind ⇒ Object
- #size ⇒ Object
- #string ⇒ Object
- #sync ⇒ Object
- #sync=(v) ⇒ Object
- #write(*ary) ⇒ Object
Instance Method Details
#close ⇒ Object
42 43 |
# File 'lib/puma/null_io.rb', line 42 def close end |
#closed? ⇒ Boolean
This is used as singleton class, so can’t have state.
71 72 73 |
# File 'lib/puma/null_io.rb', line 71 def closed? false end |
#each ⇒ Object
16 17 |
# File 'lib/puma/null_io.rb', line 16 def each end |
#eof? ⇒ Boolean
49 50 51 |
# File 'lib/puma/null_io.rb', line 49 def eof? true end |
#flush ⇒ Object
66 67 68 |
# File 'lib/puma/null_io.rb', line 66 def flush self end |
#gets ⇒ Object
8 9 10 |
# File 'lib/puma/null_io.rb', line 8 def gets nil end |
#puts(*ary) ⇒ Object
60 61 |
# File 'lib/puma/null_io.rb', line 60 def puts(*ary) end |
#read(length = nil, buffer = nil) ⇒ Object
Mimics IO#read with no data.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# 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 ⇒ Object
39 40 |
# File 'lib/puma/null_io.rb', line 39 def rewind end |
#size ⇒ Object
45 46 47 |
# File 'lib/puma/null_io.rb', line 45 def size 0 end |
#string ⇒ Object
12 13 14 |
# File 'lib/puma/null_io.rb', line 12 def string "" end |
#sync ⇒ Object
53 54 55 |
# File 'lib/puma/null_io.rb', line 53 def sync true end |
#sync=(v) ⇒ Object
57 58 |
# File 'lib/puma/null_io.rb', line 57 def sync=(v) end |
#write(*ary) ⇒ Object
63 64 |
# File 'lib/puma/null_io.rb', line 63 def write(*ary) end |