summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-10 17:22:36 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-10 17:22:36 +0200
commitd916c197fd06eb5f818e2bd75d5d1312c4758975 (patch)
tree802d8994c2bfb0bc9390e1e5785bf436db44c9f3 /lib
parent36ace535fee16efe81f17b871979f51845fb1270 (diff)
downloadedoors-ruby-d916c197fd06eb5f818e2bd75d5d1312c4758975.zip
edoors-ruby-d916c197fd06eb5f818e2bd75d5d1312c4758975.tar.gz
Room: implement resolve
Diffstat (limited to 'lib')
-rw-r--r--lib/evendoors/room.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/evendoors/room.rb b/lib/evendoors/room.rb
index d06c00f..eaa8ace 100644
--- a/lib/evendoors/room.rb
+++ b/lib/evendoors/room.rb
@@ -42,6 +42,19 @@ module EvenDoors
@spin = ( @parent.nil? ? self : @parent.spin )
end
#
+ def resolve search
+ return self if search==path
+ if (search=~/^#{path}\/(\w+)\/?/)==0
+ if spot = @spots[$1]
+ return spot if spot.path==search # needed as Door doesn't implement #resolve
+ return spot.resolve search
+ else
+ nil
+ end
+ end
+ (@parent ? @parent.resolve(search) : nil )
+ end
+ #
def try_links p
puts " -> try_links ..." if EvenDoors::Spin.debug_routing
links = @links[p.src.name]