Sha256: 37b897d4a182b7db642e47ea2e24e78d574dd45fa835f5622a6b6d07cf2d541d
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
module PPCurses class NotificationCentre def initialize @listeners = Hash.new end @@default_centre = PPCurses::NotificationCentre.new def NotificationCentre.default_centre @@default_centre end def add_observer( observer, selector, name, sender) if @listeners.has_key?(name) sender_hash = @listeners.fetch(name) else sender_hash = Hash.new @listeners.store(name, sender_hash) end sender_hash.store(sender, [observer, selector]) end def post_notification ( name, sender ) if @listeners.has_key?(name) == false then return end sender_hash = @listeners.fetch(name) if sender_hash.has_key?(sender) == false then return end listener_info = sender_hash.fetch(sender) # observer = listener_info[0] # Currently unused callback = listener_info[1] notification = Notification.new(name, sender) callback.call ( notification ) end end class Notification attr_reader :name attr_reader :object def initialize( name, object ) @name = name @object = object end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ppcurses-0.1.2 | lib/ppcurses/notification_centre.rb |
ppcurses-0.1.1 | lib/ppcurses/notification_centre.rb |