module _ToInt

A type that’s implicitly convertible to an Integer.

Implicit .to_int conversions are usable all over Ruby’s stdlib, such as Kernel#exit, File#chmod, and Array#take. Virtually anywhere that accepts an Integer will also accept something that defines .to_int.

Interestingly, types that define .to_int aren’t immediately converted in math operations on Integers (eg 1 + defines_to_int): Instead, .coerce must be defined on the right-hand-side value.