Sha256: 543e9c558f663de7f59755fa65bc45b0f2fabebd505e0816c5e71353d535db60
Contents?: true
Size: 557 Bytes
Versions: 3
Compression:
Stored size: 557 Bytes
Contents
module Buschtelefon class Brain attr_reader :capacity def initialize(capacity = 100) @capacity = capacity @gossip_sink = [] end def <<(gossip) @gossip_sink << gossip reorganize end def contains?(gossip) @gossip_sink.include?(gossip) end def to_a @gossip_sink end private def reorganize @gossip_sink.sort! { |x, y| y.created_at <=> x.created_at } @gossip_sink.uniq!(&:message) @gossip_sink.slice!(capacity..-1) # only keep the newest end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
buschtelefon-0.3.0 | lib/buschtelefon/brain.rb |
buschtelefon-0.2.0 | lib/buschtelefon/brain.rb |
buschtelefon-0.1.0 | lib/buschtelefon/brain.rb |