require 'pi_piper'
include PiPiper
watch :pin => 23 do
puts "Pin changed from #{last_value} to #{value}"
end
#Or
after :pin => 23, :goes => :high do
puts "Button pressed"
end
PiPiper.wait
pin = PiPiper::Pin.new(:pin => 17, :direction => :out)
pin.on
sleep 1
pin.off
Reference: Pi Piper gem