Question: I could use:

```
File.open('/dev/null', 'w')

```

on Unix systems, but if there is a Ruby way to achieve this, I'd like to use it. I am just looking for an I/O stream, that immediately "trashes" all writes, kind of like a null-object.

Answer: 
There's stringIO, which I find useful when I want to introduce a dummy filestream:

```
require "stringio"
f = StringIO.new
f.gets # => nil

```

And here's some code from heckle that finds the bit bucket for both Unix and Windows, slightly modified:

```
# Is this platform MS Windows-like?
# Actually, I suspect the following line is not very reliable.
WINDOWS = RUBY_PLATFORM =~ /mswin/
# Path to the bit bucket.
NULL_PATH = WINDOWS ? 'NUL:' : '/dev/null'

```
There's a gem called [devnull](https://rubygems.org/gems/devnull)

> 
> Ruby implementation of null file (like /dev/null on Un\*x, NUL on
>  Windows)
> 
> 
> 

It doesn't interact with the null file, but instead has dummy methods for all the methods that IO objects implement.