From 6867e3fb5377a7a80ad93cca2918e19e4a5fe52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 10 May 2012 22:39:32 +0200 Subject: Board: implement #to_json and #self.json_create --- lib/evendoors/board.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 -- cgit v1.1-2-g2b99