Class: Journey
- Inherits:
-
Object
- Object
- Journey
- Defined in:
- lib/flickru/journey.rb
Instance Method Summary collapse
- #distance ⇒ Object
- #elapsed ⇒ Object
-
#eta ⇒ Object
seconds.
-
#initialize(destination) ⇒ Journey
constructor
A new instance of Journey.
- #progress ⇒ Object
- #take(step) ⇒ Object
Constructor Details
#initialize(destination) ⇒ Journey
Returns a new instance of Journey.
6 7 8 9 10 11 12 13 |
# File 'lib/flickru/journey.rb', line 6 def initialize destination Ruby.assert("destination >= 0") { destination >= 0 } @distance = destination @destination = destination @beginning = Time.now @current = Time.now end |
Instance Method Details
#distance ⇒ Object
26 27 28 |
# File 'lib/flickru/journey.rb', line 26 def distance @distance end |
#elapsed ⇒ Object
30 31 32 |
# File 'lib/flickru/journey.rb', line 30 def elapsed @current - @beginning end |
#eta ⇒ Object
seconds
34 35 36 |
# File 'lib/flickru/journey.rb', line 34 def eta # seconds @distance * elapsed / progress end |
#progress ⇒ Object
22 23 24 |
# File 'lib/flickru/journey.rb', line 22 def progress @destination - @distance end |