Sha256: 24938ded4cb5046bc6a08a82cd1490b3b845082a3da0640717ce12c98b1a270c
Contents?: true
Size: 588 Bytes
Versions: 3
Compression:
Stored size: 588 Bytes
Contents
module Buschtelefon class Brain attr_reader :capacity def initialize(capacity = nil) @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) if @capacity @gossip_sink.slice!(capacity..-1) # only keep the newest end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
buschtelefon-0.4.2 | lib/buschtelefon/brain.rb |
buschtelefon-0.4.1 | lib/buschtelefon/brain.rb |
buschtelefon-0.4.0 | lib/buschtelefon/brain.rb |