Class: Howard::TimeToArrival
- Inherits:
-
Object
- Object
- Howard::TimeToArrival
- Defined in:
- lib/howard/time_to_arrival.rb
Instance Attribute Summary collapse
-
#arrival ⇒ Object
readonly
Returns the value of attribute arrival.
Instance Method Summary collapse
-
#initialize(arrival) ⇒ TimeToArrival
constructor
A new instance of TimeToArrival.
- #minutes ⇒ Object
- #to_s(format = "%d min") ⇒ Object
Constructor Details
#initialize(arrival) ⇒ TimeToArrival
Returns a new instance of TimeToArrival.
5 6 7 |
# File 'lib/howard/time_to_arrival.rb', line 5 def initialize(arrival) @arrival = arrival end |
Instance Attribute Details
#arrival ⇒ Object (readonly)
Returns the value of attribute arrival.
3 4 5 |
# File 'lib/howard/time_to_arrival.rb', line 3 def arrival @arrival end |
Instance Method Details
#minutes ⇒ Object
9 10 11 |
# File 'lib/howard/time_to_arrival.rb', line 9 def minutes (arrival.arrival_time.to_i - arrival.prediction_time.to_i) / 60 end |
#to_s(format = "%d min") ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/howard/time_to_arrival.rb', line 13 def to_s(format = "%d min") if arrival.delayed? "Delayed" elsif arrival.approaching? "Due" else format % minutes end end |