Class: NilIO

Inherits:
StringIO
  • Object
show all
Includes:
Singleton
Defined in:
lib/nilio.rb

Overview

NilIO emulates a null device (like /dev/null).

Instance Method Summary collapse

Instance Method Details

#read(length = nil, buffer = nil) ⇒ Object

Read form the null device. Always returns nil.



16
17
18
# File 'lib/nilio.rb', line 16

def read(length=nil, buffer=nil)
  nil
end

#write(string) ⇒ Object

Write to the null device. Ignores the string parameter, just returning its byte length



11
12
13
# File 'lib/nilio.rb', line 11

def write(string)
  string.to_s.bytesize
end