From 75d321ccb7af64f99e72dfff3d8f69ca9e80c959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 11 May 2012 11:25:43 +0200 Subject: Spot: compute @path, @spin add itself to @parent in initialize --- lib/evendoors/spot.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/evendoors/spot.rb b/lib/evendoors/spot.rb index fc87a32..a1106a7 100644 --- a/lib/evendoors/spot.rb +++ b/lib/evendoors/spot.rb @@ -27,22 +27,15 @@ module EvenDoors @name = n # unique in it's room @parent = p # single direct parent @viewer = nil # particle going through that position will be sent there readonly + @path = ( @parent ? @parent.path+EvenDoors::PATH_SEP : '') + @name + @spin = ( @parent ? @parent.spin : self ) + @parent.add_spot self if @parent raise EvenDoors::Exception.new "Spot name #{name} is not valid" if @name.include? EvenDoors::PATH_SEP end # - attr_reader :name + attr_reader :name, :path, :spin attr_accessor :viewer, :parent # - def path - return @path if @path - @path = ( @parent ? @parent.path+EvenDoors::PATH_SEP : '') + name - end - # - def spin - return @spin if @spin - @spin = ( @parent.nil? ? self : @parent.spin ) - end - # end # end -- cgit v1.1-2-g2b99