I believe one way to do that could be usage of #instance_eval like:
a = 'asd'
a.instance_eval do
a.upcase!
end
a # => ASD
Other way to get an object inside a block is by using #tap, but you will not have self:
gkt_window = Gtk::window.new
gtk_window.tap do |w|
w.title = 'foo'
w.resizable = false
w.foo = bar
end # Now gtk_window will have all properties set and you can chain methods to this block