Class: Timecop::Rspec::TravelLog
- Inherits:
-
Object
- Object
- Timecop::Rspec::TravelLog
- Defined in:
- lib/timecop/rspec/travel_log.rb
Overview
Tracks details about a time travel operation that can be resumed later.
Instance Method Summary collapse
-
#initialize(travel_method = nil, start_time = nil) ⇒ TravelLog
constructor
A new instance of TravelLog.
-
#pause_trip ⇒ void
Pauses the current trip, recording its duration.
-
#resume_or_new_trip(travel_method, start_time) ⇒ Object
Either resumes a previous trip or starts a new one.
Constructor Details
#initialize(travel_method = nil, start_time = nil) ⇒ TravelLog
Returns a new instance of TravelLog.
7 8 9 |
# File 'lib/timecop/rspec/travel_log.rb', line 7 def initialize(travel_method = nil, start_time = nil) new_trip(travel_method, start_time) end |
Instance Method Details
#pause_trip ⇒ void
This method returns an undefined value.
Pauses the current trip, recording its duration.
25 26 27 |
# File 'lib/timecop/rspec/travel_log.rb', line 25 def pause_trip self.trip_duration = Time.now - coalesced_start_time end |
#resume_or_new_trip(travel_method, start_time) ⇒ Object
Either resumes a previous trip or starts a new one.
15 16 17 18 19 20 21 |
# File 'lib/timecop/rspec/travel_log.rb', line 15 def resume_or_new_trip(travel_method, start_time) if resume_trip?(travel_method, start_time) resume_trip else new_trip(travel_method, start_time) end end |