Sha256: daa3c8ed83faef7e0c21d678aeadccca5e7dc288378793d82a027a6d040825f3
Contents?: true
Size: 728 Bytes
Versions: 4
Compression:
Stored size: 728 Bytes
Contents
module Buschtelefon class Tattler attr_reader :connections def initialize @connections = [] @brain = Brain.new end def load_messages(messages) messages.each { |message| @brain << Gossip.new(message) } end def knowledge @brain.to_a end def connect(tattler) @connections << tattler unless @connections.include?(tattler) end def feed(gossip) old_gossip = @brain.contains?(gossip) @brain << gossip # refresh memory return if old_gossip @connections.each { |tattler| tattler.feed(gossip) } end def transfer_knowledge(tattler) connect(tattler) knowledge.each { |gossip| tattler.feed(gossip) } end end end
Version data entries
4 entries across 4 versions & 1 rubygems