In ruby Integer class, to_s is defined to receive non required argument radix called base
, pass 2 if you want to receive binary representation of a string.
Here is a link for an official documentation of String#to_s
1.upto(10).each { |n| puts n.to_s(2) }