Sha256: 997114515fe89714a685cb6ba27b23d4c4ff4a88fc7c25e2f182990d1f57a68e
Contents?: true
Size: 735 Bytes
Versions: 1
Compression:
Stored size: 735 Bytes
Contents
module Mac module EventMonitor class Monitor def initialize @listeners = {} @any_listeners = [] end def add_listener(type = nil, &block) if type @listeners[type] ||= [] @listeners[type] << block else @any_listeners << block end end def run(stop_after = nil) run_app(stop_after) end def receive_event(str, time, screen_height) event = Event.create_from_description(str, time, screen_height) (@listeners[event.type] || []).each do |block| block.call(event) end @any_listeners.each do |block| block.call(event) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mac-event-monitor-0.2.1 | lib/mac-event-monitor/monitor.rb |