Just use Kernel#sprintf
to format the number.
Like this
x = 20
y = sprintf('\%03o', x)
puts y
output
\024
Update
Maybe I misunderstood you. If you just want a character with the given code point then just use Integer#chr
.
Like this
x = 20
y = x.chr
p y
output
"\x14"