Class: TimestampQueue
- Inherits:
-
Object
- Object
- TimestampQueue
- Defined in:
- lib/timestamp_queue.rb
Instance Method Summary collapse
- #empty? ⇒ Boolean
- #find(which, params = nil) ⇒ Object
-
#initialize ⇒ TimestampQueue
constructor
A new instance of TimestampQueue.
- #insert(key, params = nil) ⇒ Object
Constructor Details
#initialize ⇒ TimestampQueue
Returns a new instance of TimestampQueue.
4 5 6 |
# File 'lib/timestamp_queue.rb', line 4 def initialize @queue = MultiRBTree.new end |
Instance Method Details
#empty? ⇒ Boolean
27 28 29 |
# File 'lib/timestamp_queue.rb', line 27 def empty? @queue.empty? end |
#find(which, params = nil) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/timestamp_queue.rb', line 19 def find( which, params=nil ) if which == :first _find_first( params ) elsif which == :all _find_all( params ) end end |
#insert(key, params = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/timestamp_queue.rb', line 8 def insert( key, params=nil ) ts = nil if ( params.is_a?( Hash ) ) && ( params.has_key?( :timestamp ) ) ts = params[:timestamp] else ts = _current_time end @queue[ts] = key end |