Class: ShootingStar::Shooter
- Inherits:
-
Object
- Object
- ShootingStar::Shooter
- Defined in:
- lib/shooting_star/shooter.rb
Instance Method Summary collapse
- #channels ⇒ Object
- #count(channel, tag = nil) ⇒ Object
- #count_with(sig, channel, tag = nil) ⇒ Object
- #executed(sig, id) ⇒ Object
- #listeners(channel, tag = nil) ⇒ Object
- #listeners_with(uid, sig, channel, tag = nil) ⇒ Object
- #shoot(channel, id, tag) ⇒ Object
- #signature ⇒ Object
- #signatures(channel, tag = nil) ⇒ Object
- #sweep ⇒ Object
- #update(sig, uid, tag) ⇒ Object
Instance Method Details
#count(channel, tag = nil) ⇒ Object
20 21 22 |
# File 'lib/shooting_star/shooter.rb', line 20 def count(channel, tag = nil) servers(channel, tag).size end |
#count_with(sig, channel, tag = nil) ⇒ Object
24 25 26 |
# File 'lib/shooting_star/shooter.rb', line 24 def count_with(sig, channel, tag = nil) (signatures(channel, tag) | [sig]).size end |
#executed(sig, id) ⇒ Object
43 44 45 46 |
# File 'lib/shooting_star/shooter.rb', line 43 def executed(sig, id) ::ShootingStar::Server[sig].executed(id) rescue end |
#listeners(channel, tag = nil) ⇒ Object
28 29 30 |
# File 'lib/shooting_star/shooter.rb', line 28 def listeners(channel, tag = nil) servers(channel, tag).map{|s| s.uid} end |
#listeners_with(uid, sig, channel, tag = nil) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/shooting_star/shooter.rb', line 32 def listeners_with(uid, sig, channel, tag = nil) servers(channel, tag).inject([uid]) do |result, server| result << server.uid unless server.signature == sig result end end |
#shoot(channel, id, tag) ⇒ Object
6 7 8 9 10 |
# File 'lib/shooting_star/shooter.rb', line 6 def shoot(channel, id, tag) return unless Channel[channel] log "Shot: #{channel}:#{id}:#{tag.join(',')}" Channel[channel].transmit(id, :tag => tag) end |
#signature ⇒ Object
16 |
# File 'lib/shooting_star/shooter.rb', line 16 def signature; ShootingStar:: end |
#signatures(channel, tag = nil) ⇒ Object
39 40 41 |
# File 'lib/shooting_star/shooter.rb', line 39 def signatures(channel, tag = nil) servers(channel, tag).map{|s| s.signature} end |
#update(sig, uid, tag) ⇒ Object
12 13 14 |
# File 'lib/shooting_star/shooter.rb', line 12 def update(sig, uid, tag) ::ShootingStar::Server[sig].update(uid, tag || []) end |