diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-11 11:25:43 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-12 09:38:00 +0200 |
commit | 75d321ccb7af64f99e72dfff3d8f69ca9e80c959 (patch) | |
tree | f4e0a207bd9841e963e9d75d7986ea07e0b732d4 | |
parent | bbccc8d8c1a06d3a47686e5f01430b321a319ab9 (diff) | |
download | edoors-ruby-75d321ccb7af64f99e72dfff3d8f69ca9e80c959.zip edoors-ruby-75d321ccb7af64f99e72dfff3d8f69ca9e80c959.tar.gz |
Spot: compute @path, @spin add itself to @parent in initialize
-rw-r--r-- | lib/evendoors/spot.rb | 15 |
1 files 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 |