Module: ErlangHelpers

Extended by:
ErlangHelpers
Included in:
ErlangHelpers
Defined in:
lib/capricorn/driver.rb

Instance Method Summary collapse

Instance Method Details

#error(*args) ⇒ Object

Raises:



49
50
51
# File 'lib/capricorn/driver.rb', line 49

def error(*args)
  raise InternalError, args
end

#receiveObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/capricorn/driver.rb', line 36

def receive
  exit(0) if $erlin.eof?
  h = $erlin.read(4)
  while h == nil
    sleep(0.1)
    exit(0) if $erlin.eof?
    h = $erlin.read(4)
  end
  l = h.unpack('N')[0]
  exit(0) if $erlin.eof?
  BERT.decode($erlin.read(l))
end

#send(obj) ⇒ Object



30
31
32
33
34
# File 'lib/capricorn/driver.rb', line 30

def send(obj)
  berp = BERT.encode(obj)
  $erlout.write [berp.size].pack('N')+berp
  $erlout.flush
end

#setupObject



22
23
24
25
26
27
28
# File 'lib/capricorn/driver.rb', line 22

def setup
  return true if @setup
  $erlin  = IO.new(3, 'r')
  $erlout = IO.new(4, 'w')
  $erlin.sync = true
  @setup = true
end