diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-04 10:55:05 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2012-05-04 10:55:05 +0200 |
commit | 26cad1736a535e1ffcdd7771c47a31132935ae5f (patch) | |
tree | 0cc1857e57a1db0389de5af91b84a6ddc1bb32c2 /lib/evendoors/board.rb | |
parent | 462a7cd9240c652ed44c640947bcb0696e92d68b (diff) | |
download | edoors-ruby-26cad1736a535e1ffcdd7771c47a31132935ae5f.zip edoors-ruby-26cad1736a535e1ffcdd7771c47a31132935ae5f.tar.gz |
add Board class
Diffstat (limited to 'lib/evendoors/board.rb')
-rw-r--r-- | lib/evendoors/board.rb | 59 |
1 files changed, 59 insertions, 0 deletions
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 |