File: guicallback.rb

Project: Invitation to Ruby

#!/usr/bin/env ruby

class Button
  def initialize
    @callbacks = Array.new
  end
  def press
    @callbacks.each { |block| block.call }
  end
  def when_pressed(&block)
    @callbacks << block
  end
end

Used by: guicallbackdemo


[ Index ][ Table of Contents ]
Generated by [ source2html ]