summaryrefslogtreecommitdiffstats
path: root/examples/hello_world.rb
diff options
context:
space:
mode:
Diffstat (limited to 'examples/hello_world.rb')
-rw-r--r--examples/hello_world.rb50
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/hello_world.rb b/examples/hello_world.rb
new file mode 100644
index 0000000..69befd4
--- /dev/null
+++ b/examples/hello_world.rb
@@ -0,0 +1,50 @@
+#! /usr/bin/env ruby
+# -*- coding: UTF-8 -*-
+#
+# run from project top directory with : ruby -Ilib examples/hello_world.rb
+#
+require 'edoors'
+#
+class InputDoor < Edoors::Door
+ #
+ def start!
+ # stimulate myself
+ send_p require_p(Edoors::Particle), Edoors::ACT_GET
+ end
+ #
+ def receive_p p
+ if p.action==Edoors::ACT_GET
+ p.reset!
+ p.set_data 'txt', "hello world"
+ send_p p # will follow the default link
+ else
+ puts p.action
+ # we can release it or let the Door do it
+ release_p p
+ end
+ end
+ #
+end
+#
+class OutputDoor < Edoors::Door
+ #
+ def receive_p p
+ puts p.get_data('txt')
+ # let the door release it
+ end
+ #
+end
+#
+if $0 == __FILE__
+ #
+ dom0 = Edoors::Spin.new 'dom0'
+ input = InputDoor.new 'input', dom0
+ output = OutputDoor.new 'output', dom0
+ dom0.add_link Edoors::Link.new('input', 'output', nil, nil, nil)
+ #
+ dom0.spin!
+ dom0.hibernate!
+ #
+end
+#
+# EOF