Module: Jello

Defined in:
lib/jello.rb,
lib/jello/mould.rb,
lib/jello/pasteboard.rb

Defined Under Namespace

Classes: Mould, Pasteboard

Constant Summary collapse

Version =
2
Moulds =

A hash of each pasteboard and the moulds that preform on that pasteboard.

Pasteboards.inject(Hash.new) {|h,pb| h[pb] = Array.new ; h }
Pasteboards =
[]

Class Method Summary collapse

Class Method Details

.start!(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/jello.rb', line 8

def self.start! options = {}
  options = {:verbose => false, :period => 0.5}.merge(options)
  
  forever do
    
    Moulds.each do |pasteboard, moulds|
      if (paste = pasteboard.gets) != pasteboard.last
        initial_paste = paste.dup
        
        puts "#{pasteboard.board} received: [#{initial_paste}]" if options[:verbose]
        moulds.each do |mould|
          paste = mould.on_paste[paste]
        end
        
        if paste.is_a?(String) and paste != initial_paste
          puts " --> [#{paste}]" if options[:verbose]
          pasteboard.puts paste 
        end
      end
    end
    
    sleep options[:period]
  end
end

.stop!Object

Raises:

  • (Interrupt)


33
34
35
# File 'lib/jello.rb', line 33

def self.stop!
  raise Interrupt # …
end