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: 
No, I don't believe there is anything like a null stream in Ruby, at least in earlier versions. In that case, you must make one yourself. Depending on the methods that it will call, you will need to write
stub methods on the null stream class, like this:

```
class NullStream
   def <<(o); self; end
end

```

The above example is by no means complete. For example, some streams may require calling the `write`, `puts` or other methods. Moreover, some methods should be implemented by returning `self` in their methods, like `<<`, others not.
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.