Module: Lite::Containers::TopN::Abstract
Instance Attribute Summary collapse
Instance Method Summary
collapse
#<<
#count, #empty?, #length, #size
Instance Attribute Details
#limit ⇒ Object
Returns the value of attribute limit.
25
26
27
|
# File 'lib/lite/containers/top_n/abstract.rb', line 25
def limit
@limit
end
|
Instance Method Details
#drain! ⇒ Object
34
35
36
|
# File 'lib/lite/containers/top_n/abstract.rb', line 34
def drain!
@backend.drain!
end
|
#initialize(backend, limit, filter) ⇒ Object
19
20
21
22
23
|
# File 'lib/lite/containers/top_n/abstract.rb', line 19
def initialize(backend, limit, filter)
@backend = backend
@limit = limit
@filter = filter
end
|
#push(new_item) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/lite/containers/top_n/abstract.rb', line 27
def push(new_item)
return unless pass?(new_item)
@backend.push(new_item)
shrink
end
|