Module: OCTranspo::Route
Instance Method Summary collapse
- #all ⇒ Object
- #find_all_matching(pattern) ⇒ Object
- #find_by_number(number) ⇒ Object
- #find_by_route_id(route_id) ⇒ Object
- #storage ⇒ Object
Instance Method Details
#all ⇒ Object
7 8 9 |
# File 'lib/octranspo/route.rb', line 7 def all @routes ||= YAML.load_file(storage) end |
#find_all_matching(pattern) ⇒ Object
21 22 23 24 25 |
# File 'lib/octranspo/route.rb', line 21 def find_all_matching (pattern) all.select do |route| pattern.match route[:name] end end |
#find_by_number(number) ⇒ Object
15 16 17 18 19 |
# File 'lib/octranspo/route.rb', line 15 def find_by_number (number) all.detect do |route| route[:number] == number end end |
#find_by_route_id(route_id) ⇒ Object
11 12 13 |
# File 'lib/octranspo/route.rb', line 11 def find_by_route_id (route_id) find_by_number route_id.to_s.split('-').first end |
#storage ⇒ Object
27 28 29 |
# File 'lib/octranspo/route.rb', line 27 def storage "#{File.dirname(__FILE__)}/routes.yml" end |