Sha256: ab1ece7795c62c6c94afd6d65b365ba6ad41c56c73d243bbb52070cee21fec3d

Contents?: true

Size: 454 Bytes

Versions: 1

Compression:

Stored size: 454 Bytes

Contents

#!/usr/bin/env ruby
$:.unshift File.expand_path '../lib', File.dirname(__FILE__)
require 'event_emitter'

class Foo
  include EventEmitter
end

foo = Foo.new

foo.on 'chat' do |data|
  puts "chat - #{data[:user]} : #{data[:message]}"
end

foo.on 'sum' do |data|
  puts data.inject{|a,b|
    a+b
  }
end

foo.emit 'chat', {:user => 'shokai', :message => 'hello world'}
foo.emit :chat, :user => 'ymrl', :message => 'hello work'

foo.emit 'sum', [1,2,3,45]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
event_emitter-0.0.1 samples/sample.rb