Separate example Ruby code

This commit is contained in:
Ian Adam Naval 2015-04-29 17:14:31 -04:00
parent fef310d35c
commit 95a1c98fb8
2 changed files with 27 additions and 25 deletions

27
ruby/example.rb Normal file
View File

@ -0,0 +1,27 @@
$LOAD_PATH << '.'
require "jsh"
def main
s = Stream.new $stdout, 4
s.start!
7.times do |i|
proc = {:pid => i + 1, :name => "init"}
s.output(:things, proc)
end
q = s.new_stream 'q'
q.output(:test, 'potato')
10.times do |i|
proc = {:pid => i + 1, :name => "init"}
s.output(:processes, proc)
end
q.output(:test, "salad")
q.output(:test, "rocks")
s.flush
s.stop!
end
main

View File

@ -118,28 +118,3 @@ class Stream
end end
end end
def main
s = Stream.new $stdout, 4
s.start!
7.times do |i|
proc = {:pid => i + 1, :name => "init"}
s.output(:things, proc)
end
q = s.new_stream 'q'
q.output(:test, 'potato')
10.times do |i|
proc = {:pid => i + 1, :name => "init"}
s.output(:processes, proc)
end
q.output(:test, "salad")
q.output(:test, "rocks")
s.flush
s.stop!
end
main