Class: Muni::Direction

Inherits:
Base
  • Object
show all
Defined in:
lib/muni/direction.rb

Instance Method Summary collapse

Instance Method Details

#stop_at(place) ⇒ Object



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

def stop_at(place)
  if stop = stops.detect { |stop| stop.tag == place }
    return stop
  end

  if stop = stops.detect { |stop| stop.title == place }
    return stop
  end

  pattern = Amatch::Sellers.new(place)
  stops.sort_by{ |stop|
    pattern.match(stop.title)
  }.first
end