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: 
If you want the full behavior of streams, the best is probably to use:

```
File.open(File::NULL, "w")

```

Note that `File::NULL` is new to Ruby 1.9.3; you can use my [`backports`](https://github.com/marcandre/backports) gem:

```
require 'backports/1.9.3/file/null' # => Won't do anything in 1.9.3+
File.open(File::NULL, "w")          # => works even in Ruby 1.8.6

```

You could also copy the [relevant code](https://github.com/marcandre/backports/blob/master//lib/backports/1.9.3/file/null.rb) if you prefer.
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.