Class: Transilien::StopPoint

Inherits:
MicroService show all
Defined in:
lib/transilien/stop_point.rb

Constant Summary

Constants inherited from MicroService

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

Instance Attribute Summary

Attributes inherited from MicroService

#access_time, #external_code, #name, #payload

Instance Method Summary collapse

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, from_node, http, params, #to_s

Instance Method Details

#addressObject Also known as: stop_point_address



6
7
8
# File 'lib/transilien/stop_point.rb', line 6

def address
  payload.at('StopPointAddress')
end

#cityObject



26
27
28
# File 'lib/transilien/stop_point.rb', line 26

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

#coordObject



35
36
37
38
39
40
# File 'lib/transilien/stop_point.rb', line 35

def coord
  @coord ||= {
    x: payload.at('Coord').at('CoordX').content.sub(',','.').to_f,
    y: payload.at('Coord').at('CoordY').content.sub(',','.').to_f
  }
end

#equipmentObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/transilien/stop_point.rb', line 11

def equipment
  @equipment ||= {
      sheltered:     (payload.at('Equipment')['Sheltered']    == 'True'),
      mimp_access:   (payload.at('Equipment')['MIPAccess']    == 'True'),
      elevator:      (payload.at('Equipment')['Elevator']     == 'True'),
      escalator:     (payload.at('Equipment')['Escalator']    == 'True'),
      bike_accepted: (payload.at('Equipment')['BikeAccepted'] == 'True'),
      bike_depot:    (payload.at('Equipment')['BikeDepot']    == 'True')
    }
end

#fare_zoneObject



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

def fare_zone
  @fare_zone ||= payload['FareZone']
end

#modeObject



22
23
24
# File 'lib/transilien/stop_point.rb', line 22

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

#stop_areaObject



30
31
32
33
# File 'lib/transilien/stop_point.rb', line 30

def stop_area
  #@stop_area ||= Transilien::StopArea.from_node(payload.at('StopArea'), access_time)
  @stop_area ||= Transilien::StopArea.find(stop_area_external_code: payload.at('StopArea')['StopAreaExternalCode']).first
end