Inhibiting Suspend
The interface is a bit low level, but workable:
require 'dbus' # gem install ruby-dbus
bus = DBus::SessionBus.instance
sm = bus.service('org.gnome.SessionManager').object('/org/gnome/SessionManager')
sm.introspect
sm.default_iface = 'org.gnome.SessionManager'
cookie = sm.Inhibit($0, 0, 'inhibiting', 4).first
at_exit { cookie = sm.Uninhibit(cookie) if sm.IsInhibited(4).first }
Note: the call to Uninhibit is optional — it will occur on process exit anyway.
Hat tip to JanuZ.