Sha256: a631b8c55b9710f92f100d5d0fc94fa8a84f7ed850b8e600ccb741da087cbf1d
Contents?: true
Size: 549 Bytes
Versions: 13
Compression:
Stored size: 549 Bytes
Contents
#!/usr/bin/env ruby $:.unshift File.expand_path '../lib', File.dirname(__FILE__) require 'event_emitter' class User attr_accessor :name def initialize(name) @name = name end end shokai = User.new "shokai" ymrl = User.new "ymrl" EventEmitter.apply shokai ## set instance-specific method shokai.on :go do |data| puts "#{name} go to #{data[:place]}" end shokai.emit :go, :place => "chiba city" ## raise undefined-method error begin ymrl.on :go do |data| puts "#{name} go to #{data[:place]}" end rescue => e STDERR.puts e end
Version data entries
13 entries across 13 versions & 2 rubygems