Sha256: 6c2d9688f501981ffa050b0d1d15e1bc3762ed6b13e55670b7e4b3ae1c8c833b
Contents?: true
Size: 689 Bytes
Versions: 9
Compression:
Stored size: 689 Bytes
Contents
#!/usr/bin/env ruby $:.unshift File.expand_path '../lib', File.dirname(__FILE__) require 'event_emitter' class User include EventEmitter attr_accessor :name def initialize(name) @name = name end end shokai = User.new 'shokai' ymrl = User.new 'ymrl' shokai.on :go do |data| puts "#{name} go to #{data[:place]}" end ymrl.on :go do |data| puts "#{name} go to #{data[:place]}" end shokai.emit :go, {:place => 'mountain'} ymrl.emit :go, :place => 'cyberspace' shokai.once :eat do |what, where| puts "#{name} -> #{what} at #{where}" end shokai.emit :eat, 'BEEF', 'zanmai' shokai.emit :eat, 'Ramen', 'marutomo' # do not call. call only first time if regist with "once"
Version data entries
9 entries across 9 versions & 2 rubygems