Class: Logpos::TripleArray
- Inherits:
-
Object
- Object
- Logpos::TripleArray
- Defined in:
- lib/logpos.rb
Defined Under Namespace
Classes: TP
Instance Method Summary collapse
- #include?(time) ⇒ Boolean
-
#initialize(lastest_visited_at) ⇒ TripleArray
constructor
A new instance of TripleArray.
- #oldest ⇒ Object
- #push(time, pos) ⇒ Object
Constructor Details
#initialize(lastest_visited_at) ⇒ TripleArray
Returns a new instance of TripleArray.
69 70 71 72 |
# File 'lib/logpos.rb', line 69 def initialize lastest_visited_at @lastest_visited_at = lastest_visited_at @array = Array.new(3, TP.new(0, Time.at(0))) end |
Instance Method Details
#include?(time) ⇒ Boolean
82 83 84 |
# File 'lib/logpos.rb', line 82 def include? time !!@array.detect {|tp| tp.time == time } end |
#oldest ⇒ Object
86 87 88 |
# File 'lib/logpos.rb', line 86 def oldest @array.select {|a| a.time <= @lastest_visited_at }.sort {|a, b| a.time <=> b.time}[-1] end |