Sha256: 137186859221f404f4ec7adf0fb775502f04312618b8b348ec5279a1d5781b79
Contents?: true
Size: 494 Bytes
Versions: 2
Compression:
Stored size: 494 Bytes
Contents
# frozen_string_literal: true module Sniffer # Data class stores the data and controls capacity class Data < Array def store(data_item) if config.rotate? rotate(data_item) else push(data_item) unless overflow? end end private def rotate(data_item) shift if overflow? push(data_item) end def overflow? config.capacity? && length >= config.capacity end def config Sniffer.config end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sniffer-0.5.0 | lib/sniffer/data.rb |
sniffer-0.4.0 | lib/sniffer/data.rb |