Class: Roundtrip::Core
- Inherits:
-
Object
- Object
- Roundtrip::Core
- Defined in:
- lib/roundtrip/core.rb
Instance Method Summary collapse
- #checkpoint(id, at) ⇒ Object
- #end(id) ⇒ Object
-
#initialize(store, metrics = Roundtrip::Metrics::Null.new) ⇒ Core
constructor
A new instance of Core.
- #pending(route, older_than = 0) ⇒ Object
- #purge(route, older_than = 0) ⇒ Object
- #start(route, opts = {}) ⇒ Object
Constructor Details
#initialize(store, metrics = Roundtrip::Metrics::Null.new) ⇒ Core
Returns a new instance of Core.
4 5 6 7 |
# File 'lib/roundtrip/core.rb', line 4 def initialize(store, metrics=Roundtrip::Metrics::Null.new) @store = store @metrics = metrics end |
Instance Method Details
#checkpoint(id, at) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/roundtrip/core.rb', line 17 def checkpoint(id, at) must_be_present! id, at trip = @store.get(id) if trip res = @store.add_checkpoint(trip, at) @metrics.time(trip.route, at, msec(res[1] - trip.started_at)) res end end |
#end(id) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/roundtrip/core.rb', line 27 def end(id) must_be_present! id trip = @store.get(id) end_trip(trip) if trip trip end |
#pending(route, older_than = 0) ⇒ Object
35 36 37 38 39 |
# File 'lib/roundtrip/core.rb', line 35 def pending(route, older_than=0) must_be_present! route @store.pending_trips(route, older_than) end |
#purge(route, older_than = 0) ⇒ Object
41 42 43 44 45 |
# File 'lib/roundtrip/core.rb', line 41 def purge(route, older_than=0) pending_trips = pending(route, older_than) pending_trips.each{ |trip| end_trip(trip) } pending_trips end |