Class: Transilien::Stop

Inherits:
FakeMicroService show all
Defined in:
lib/transilien/stop.rb

Constant Summary

Constants inherited from MicroService

MicroService::API_HOST, MicroService::API_URI, MicroService::Default_cache_duration

Instance Attribute Summary collapse

Attributes inherited from MicroService

#access_time, #external_code, #payload

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FakeMicroService

http

Methods inherited from MicroService

action, action_component, action_instance_xpath, action_param, add_filters, cache_it, cache_keys, errors, filters, filters=, find, find_from_full_query_cache, find_from_query_caches, http, params, #to_s

Instance Attribute Details

#arrival_timeObject

Returns the value of attribute arrival_time.



2
3
4
# File 'lib/transilien/stop.rb', line 2

def arrival_time
  @arrival_time
end

#name_at_stopObject

Returns the value of attribute name_at_stop.



2
3
4
# File 'lib/transilien/stop.rb', line 2

def name_at_stop
  @name_at_stop
end

#stop_timeObject

Returns the value of attribute stop_time.



2
3
4
# File 'lib/transilien/stop.rb', line 2

def stop_time
  @stop_time
end

Class Method Details

.from_node(node, access_time) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/transilien/stop.rb', line 5

def from_node(node, access_time)
  item = new
  item.payload = node

  stop_node = node.at('StopTime')
  item.stop_time = !stop_node.children.empty? && ::Transilien::Time.from_node(stop_node, access_time)

  arrival_node = node.at('StopArrivalTime')
  item.arrival_time = !arrival_node.children.empty? && ::Transilien::Time.from_node(arrival_node, access_time)

  item.name_at_stop = node.at('VehicleJourneyNameAtStop') && node.at('VehicleJourneyNameAtStop').text
  item
end

Instance Method Details

#nameObject

objective: enable caching



24
25
26
# File 'lib/transilien/stop.rb', line 24

def name # objective: enable caching
  "#{stop_time.name}||#{arrival_time.name}"
end

#stop_pointObject



20
21
22
# File 'lib/transilien/stop.rb', line 20

def stop_point
  @stop_point ||= Transilien::StopPoint.from_node(payload.at('StopPoint'), access_time)
end