Class: Surrender::MostRecentPolicy
- Inherits:
-
Object
- Object
- Surrender::MostRecentPolicy
- Defined in:
- lib/surrender/most_recent_policy.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#memo ⇒ Object
(also: #keys)
readonly
Returns the value of attribute memo.
Instance Method Summary collapse
- #add(filename, _) ⇒ Object
- #deleteable?(filename) ⇒ Boolean
-
#initialize(count) ⇒ MostRecentPolicy
constructor
A new instance of MostRecentPolicy.
- #name ⇒ Object
Constructor Details
#initialize(count) ⇒ MostRecentPolicy
3 4 5 6 |
# File 'lib/surrender/most_recent_policy.rb', line 3 def initialize(count) @count = count @memo = [] end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
8 9 10 |
# File 'lib/surrender/most_recent_policy.rb', line 8 def count @count end |
#memo ⇒ Object (readonly) Also known as: keys
Returns the value of attribute memo.
8 9 10 |
# File 'lib/surrender/most_recent_policy.rb', line 8 def memo @memo end |
Instance Method Details
#add(filename, _) ⇒ Object
14 15 16 17 |
# File 'lib/surrender/most_recent_policy.rb', line 14 def add(filename, _) memo << filename memo.shift if memo.size > count end |
#deleteable?(filename) ⇒ Boolean
19 20 21 |
# File 'lib/surrender/most_recent_policy.rb', line 19 def deleteable?(filename) !memo.include?(filename) end |
#name ⇒ Object
10 11 12 |
# File 'lib/surrender/most_recent_policy.rb', line 10 def name "most recent" end |