class Foo def initialize(str) @str = str end def *(num) num.times.map { @str }.join('') end end foo = Foo.new('hello') foo * 4 #=> "hellohellohellohello"