Sha256: c3e68d45e5264e74374eeba836c5925738ed03ab577ca9c4d4d8b0f01c54580f

Contents?: true

Size: 402 Bytes

Versions: 3

Compression:

Stored size: 402 Bytes

Contents

module Surrender
  class BucketPolicy
    def initialize(count)
      @count = count
      @memo  = Hash.new
    end

    attr_reader :count, :memo

    def add(filename, date)
      memo[bucket(date)] = filename
      memo.delete(memo.keys.first) if memo.size > count
    end

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

    def keys
      memo.keys
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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