Class: Howard::Arrival

Inherits:
Object
  • Object
show all
Defined in:
lib/howard/arrival.rb

Instance Method Summary collapse

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?

Returns:

  • (Boolean)


25
26
27
# File 'lib/howard/arrival.rb', line 25

def approaching?
  @api_response.fetch("isApp", "0") == "1"
end

#arrival_timeObject



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

Returns:

  • (Boolean)


42
43
44
# File 'lib/howard/arrival.rb', line 42

def delayed?
  @api_response.fetch("isDly", "0") == "1"
end

#etaObject



21
22
23
# File 'lib/howard/arrival.rb', line 21

def eta
  @eta ||= TimeToArrival.new(self)
end

#fault?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/howard/arrival.rb', line 38

def fault?
  @api_response.fetch("isFlt", "0") == "1"
end

#live?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/howard/arrival.rb', line 34

def live?
  !scheduled?
end

#prediction_timeObject



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

Returns:

  • (Boolean)


30
31
32
# File 'lib/howard/arrival.rb', line 30

def scheduled?
  @api_response.fetch("isSch", "0") == "1"
end

#trainObject



9
10
11
# File 'lib/howard/arrival.rb', line 9

def train
  @train ||= Train.new(@api_response)
end