summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-04 10:55:05 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-04 10:55:05 +0200
commit26cad1736a535e1ffcdd7771c47a31132935ae5f (patch)
tree0cc1857e57a1db0389de5af91b84a6ddc1bb32c2
parent462a7cd9240c652ed44c640947bcb0696e92d68b (diff)
downloadedoors-ruby-26cad1736a535e1ffcdd7771c47a31132935ae5f.zip
edoors-ruby-26cad1736a535e1ffcdd7771c47a31132935ae5f.tar.gz
add Board class
-rw-r--r--lib/evendoors.rb1
-rw-r--r--lib/evendoors/board.rb59
2 files changed, 60 insertions, 0 deletions
diff --git a/lib/evendoors.rb b/lib/evendoors.rb
index 305259b..408549e 100644
--- a/lib/evendoors.rb
+++ b/lib/evendoors.rb
@@ -35,6 +35,7 @@ require 'evendoors/twirl'
require 'evendoors/room'
require 'evendoors/space'
require 'evendoors/door'
+require 'evendoors/board'
require 'evendoors/link'
#
# EOF
diff --git a/lib/evendoors/board.rb b/lib/evendoors/board.rb
new file mode 100644
index 0000000..e8c5053
--- /dev/null
+++ b/lib/evendoors/board.rb
@@ -0,0 +1,59 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+
+#
+module EvenDoors
+ #
+ class Board < Spot
+ #
+ def initialize n, p=nil
+ super n, p
+ @saved = nil
+ @spots = {}
+ @parent.add_spot self if @parent
+ end
+ #
+ def require_p p_kls
+ p = EvenDoors::Twirl.require_p p_kls
+ p.src = self
+ p
+ end
+ #
+ def release_p p
+ @saved=nil if @saved==p # particle is released, all is good
+ EvenDoors::Twirl.release_p p
+ end
+ #
+ def process_p p
+ @viewer.receive_p p if @viewer
+ p2 = @spots[p.link_value] ||= p
+ return if p2==p
+ p,p2 = p2,p if p.action==EvenDoors::ACT_FOLLOW
+ p.merge! p2
+ @saved = p
+ receive_p p
+ if not @saved.nil?
+ puts "#{path} didn't give that particle back #{p}" if EvenDoors::Twirl.debug
+ puts "\t#{p.data EvenDoors::ERROR_FIELD}" if p.action==EvenDoors::ACT_ERROR
+ release_p @saved
+ @saved = nil
+ end
+ end
+ #
+ def send_p p
+ p.src = self
+ @saved=nil if @saved==p # particle is sent back the data, all is good
+ @parent.send_p p # daddy will know what to do
+ end
+ #
+ def send_sys_p p
+ p.src = self
+ @saved=nil if @saved==p # particle is sent back the data, all is good
+ @parent.send_sys_p p # daddy will know what to do
+ end
+ #
+ end
+ #
+end
+#
+# EOF