Class: ShootingStar::Shooter

Inherits:
Object
  • Object
show all
Defined in:
lib/shooting_star/shooter.rb

Instance Method Summary collapse

Instance Method Details

#channelsObject



17
# File 'lib/shooting_star/shooter.rb', line 17

def channels; Channel.list end

#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

#signatureObject



16
# File 'lib/shooting_star/shooter.rb', line 16

def signature; ShootingStar::timestamp 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

#sweepObject



18
# File 'lib/shooting_star/shooter.rb', line 18

def sweep; Channel.sweep 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