Class: Howard::Arrival
- Inherits:
-
Object
- Object
- Howard::Arrival
- Defined in:
- lib/howard/arrival.rb
Instance Method Summary collapse
- #approaching? ⇒ Boolean (also: #due?)
- #arrival_time ⇒ Object
- #delayed? ⇒ Boolean
- #eta ⇒ Object
- #fault? ⇒ Boolean
-
#initialize(api_response) ⇒ Arrival
constructor
A new instance of Arrival.
- #live? ⇒ Boolean
- #prediction_time ⇒ Object
- #scheduled? ⇒ Boolean
- #train ⇒ Object
Constructor Details
#initialize(api_response) ⇒ Arrival
Returns a new instance of Arrival.
5 6 7 |
# File 'lib/howard/arrival.rb', line 5 def initialize(api_response) @api_response = api_response end |
Instance Method Details
#approaching? ⇒ Boolean Also known as: due?
25 26 27 |
# File 'lib/howard/arrival.rb', line 25 def approaching? @api_response.fetch("isApp", "0") == "1" end |
#arrival_time ⇒ Object
17 18 19 |
# File 'lib/howard/arrival.rb', line 17 def arrival_time Time.strptime(@api_response["arrT"], "%Y%m%d %H:%M:%S") end |
#delayed? ⇒ Boolean
42 43 44 |
# File 'lib/howard/arrival.rb', line 42 def delayed? @api_response.fetch("isDly", "0") == "1" end |
#eta ⇒ Object
21 22 23 |
# File 'lib/howard/arrival.rb', line 21 def eta @eta ||= TimeToArrival.new(self) end |
#fault? ⇒ Boolean
38 39 40 |
# File 'lib/howard/arrival.rb', line 38 def fault? @api_response.fetch("isFlt", "0") == "1" end |
#live? ⇒ Boolean
34 35 36 |
# File 'lib/howard/arrival.rb', line 34 def live? !scheduled? end |
#prediction_time ⇒ Object
13 14 15 |
# File 'lib/howard/arrival.rb', line 13 def prediction_time Time.strptime(@api_response["prdt"], "%Y%m%d %H:%M:%S") end |
#scheduled? ⇒ Boolean
30 31 32 |
# File 'lib/howard/arrival.rb', line 30 def scheduled? @api_response.fetch("isSch", "0") == "1" end |