class EasyTransilien::Station

Attributes

access_time[RW]
external_code[RW]
ms_stop_area[RW]
name[RW]

Public Class Methods

all_stop_areas(options = {}) click to toggle source

Get all available `Transilien::StopArea`

See:

`transilien_microservices` gem

# File lib/easy_transilien/station.rb, line 10
def all_stop_areas(options = {})
  options[:force] ||= false
  if options[:force] || @all_stop_areas.nil?
    @all_stop_areas = ::Transilien::StopArea.find
  end
  @all_stop_areas
end
convert_stop_areas_to_stations(stop_areas) click to toggle source
# File lib/easy_transilien/station.rb, line 41
def convert_stop_areas_to_stations(stop_areas)
  stop_areas.map do |sa|  
    item = new
    item.name          = sa.name
    item.external_code = sa.external_code
    item.access_time   = sa.access_time
    item.ms_stop_area  = sa
    item
  end
end
find(criterium = nil) click to toggle source

Find a list of `Station` matching criterium. Valid keys: @param [String] criterium will try to match name or external_code. Both case unsensitive.

# File lib/easy_transilien/station.rb, line 21
def find(criterium = nil)
  if criterium.is_a?(String)
    regex = /#{criterium}/i
    matching = all_stop_areas.reject { |sa| sa.name !~ regex && sa.external_code !~ regex }
    return convert_stop_areas_to_stations(matching)
  elsif criterium.is_a?(Station)
    return [criterium]
  elsif criterium.is_a?(Hash)
    matching = []
    if criterium.keys.include?(:line_external_code)
      all_stop_areas.select { |sa| raise sa.inspect }
    end
    return convert_stop_areas_to_stations(matching)
  elsif criterium.nil?
    return convert_stop_areas_to_stations(all_stop_areas)
  else
    raise 'WAZZUF?'
  end
end

Public Instance Methods

codes() click to toggle source
# File lib/easy_transilien/station.rb, line 58
def codes
   @codes ||= ms_stop_area.lines.map(&:code).flatten.uniq.sort#.reject { |c| c.length != 1 } # DEV NOTE lines with more than 1 letter are special lines for "travaux"
end
coord(format = :gps) click to toggle source
# File lib/easy_transilien/station.rb, line 62
def coord(format = :gps)
  if format == :gps
  end
end
lines() click to toggle source
# File lib/easy_transilien/station.rb, line 54
def lines
  @lines ||= EasyTransilien::Line.find()
end