lib/easy_transilien/station.rb in easy_transilien-0.0.1 vs lib/easy_transilien/station.rb in easy_transilien-0.0.2

- old
+ new

@@ -1,8 +1,9 @@ module EasyTransilien class Station attr_accessor :name, :external_code, :access_time + attr_accessor :ms_stop_area class << self # Get all available `Transilien::StopArea` # == See: # `transilien_microservices` gem @@ -22,24 +23,46 @@ 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 def convert_stop_areas_to_stations(stop_areas) stop_areas.map do |sa| item = new - item.name = sa.name + item.name = sa.name item.external_code = sa.external_code - item.access_time = sa.access_time + item.access_time = sa.access_time + item.ms_stop_area = sa item end end + end + + def lines + @lines ||= EasyTransilien::Line.find() + end + + 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 + + def coord(format = :gps) + if format == :gps + end end end end