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

Version Path
event_emitter-0.2.6 samples/instance-specific-method.rb
event_emitter-with_instance_listener-0.2.5 samples/instance-specific-method.rb
event_emitter-0.2.5 samples/instance-specific-method.rb
event_emitter-0.2.4 samples/instance-specific-method.rb
event_emitter-0.2.3 samples/instance-specific-method.rb
event_emitter-0.2.2 samples/instance-specific-method.rb
event_emitter-0.2.1 samples/instance-specific-method.rb
event_emitter-0.2.0 samples/instance-specific-method.rb
event_emitter-0.1.0 samples/instance-specific-method.rb
event_emitter-0.0.7 samples/instance-specific-method.rb
event_emitter-0.0.6 samples/instance-specific-method.rb
event_emitter-0.0.5 samples/instance-specific-method.rb
event_emitter-0.0.4 samples/instance-specific-method.rb