Sha256: b708a49e2212e06877c098d5cd82f17e0e869d3587a6c92a1c64e01a000e73e1

Contents?: true

Size: 352 Bytes

Versions: 3

Compression:

Stored size: 352 Bytes

Contents

module Surrender
  class MostRecentPolicy
    def initialize(count)
      @count = count
      @memo  = []
    end

    attr_reader :count, :memo

    def add(filename, _)
      memo << filename
      memo.shift if memo.size > count
    end

    def deleteable?(filename)
      !memo.include?(filename)
    end

    alias_method :keys, :memo
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
surrender-0.8.2 lib/surrender/most_recent_policy.rb
surrender-0.8.1 lib/surrender/most_recent_policy.rb
surrender-0.8.0 lib/surrender/most_recent_policy.rb