summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-10 22:39:32 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-10 22:39:32 +0200
commit6867e3fb5377a7a80ad93cca2918e19e4a5fe52b (patch)
tree2256476d9f90efa0a3420afc75b7313d350c0fbf /lib
parentd5da9a6ba1aa802201671af973e028620286681b (diff)
downloadedoors-ruby-6867e3fb5377a7a80ad93cca2918e19e4a5fe52b.zip
edoors-ruby-6867e3fb5377a7a80ad93cca2918e19e4a5fe52b.tar.gz
Board: implement #to_json and #self.json_create
Diffstat (limited to 'lib')
-rw-r--r--lib/evendoors/board.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/evendoors/board.rb b/lib/evendoors/board.rb
index ead1012..b9b01cd 100644
--- a/lib/evendoors/board.rb
+++ b/lib/evendoors/board.rb
@@ -11,6 +11,23 @@ module EvenDoors
@postponed = {}
end
#
+ def to_json *a
+ {
+ 'kls' => self.class.name,
+ 'name' => @name,
+ 'postponed' => @postponed
+ }.to_json *a
+ end
+ #
+ def self.json_create o
+ raise EvenDoors::Exception.new "JSON #{o['kls']} != #{self.name}" if o['kls'] != self.name
+ board = self.new o['name']
+ o['postponed'].each do |lv,p|
+ board.process_p EvenDoors::Particle.json_create p
+ end
+ board
+ end
+ #
def process_p p
@viewer.receive_p p if @viewer
if p.action!=EvenDoors::ACT_ERROR