Просто верните внутреннее значение из блока. Также убедитесь, что в случае возникновения исключения вы оставляете в согласованном состоянии:
class MyWatir < Watir::Browser
def with_watir_window(win)
cw = window #current window
win.use
# the begin/end will evaluate to the value returned by `yield`.
# if an exception occurs, the window will be reset properly and
# there will be no return value.
begin
yield
ensure
cw.use
end
end
def qty
with_watir_window(@win2) do
td(:id,'qty').text
end
end
end