broadcast-objects 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/broadcast-objects.rb +23 -0
  2. metadata +48 -0
@@ -0,0 +1,23 @@
1
+ class Channel
2
+ def initialize
3
+ @subscribers = []
4
+ end
5
+ def broadcast data
6
+ for i in subscribers
7
+ subscribers.recieve(self, data)
8
+ end
9
+ end
10
+ attr_accessor :subscribers
11
+ end
12
+ module Broadcasting
13
+ def subscribe channel
14
+ channel.subscribers.push self
15
+ end
16
+ def send(channel, data)
17
+ channel.broadcast data
18
+ end
19
+ def recieve(channel, data)
20
+ #always override in child class. Here for debug purposes
21
+ puts (data.to_s)+" was sent on channel "+(channel.to_s)+" and recieved by object "+(self.to_s)+" which did not implement the recieve function. Something is probably wrong"
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: broadcast-objects
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eigil Rischel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-02 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: ! "broadcast-objects is a small gem that enables mass communication between
15
+ objects. While this is usually restricted to communication to a singular\n\tobject,
16
+ broadcast-objects lets you 'broadcast' to many objects at once, and gives you full
17
+ control over which objects recieve which broadcasts."
18
+ email: ayegill@gmail.com
19
+ executables: []
20
+ extensions: []
21
+ extra_rdoc_files: []
22
+ files:
23
+ - lib/broadcast-objects.rb
24
+ homepage: http://rubygems.org/gems/broadcast-objects
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.11
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: Simple system to let objects communicate en masse
48
+ test_files: []