Class: Goru::Routines::Bridge

Inherits:
Goru::Routine show all
Defined in:
lib/goru/routines/bridge.rb

Overview

public

Instance Attribute Summary

Attributes inherited from Goru::Routine

#state, #status

Instance Method Summary collapse

Methods inherited from Goru::Routine

#call, #finished, #reactor=, #result, #sleep, #update, #wake

Constructor Details

#initialize(state = nil, routine:, channel:, &block) ⇒ Bridge

Returns a new instance of Bridge.



10
11
12
13
14
15
16
# File 'lib/goru/routines/bridge.rb', line 10

def initialize(state = nil, routine:, channel:, &block)
  super(state, &block)

  @routine = routine
  @channel = channel
  @channel.add_observer(self)
end

Instance Method Details

#channel_closedObject



41
42
43
# File 'lib/goru/routines/bridge.rb', line 41

def channel_closed
  update_status
end

#channel_readObject



37
38
39
# File 'lib/goru/routines/bridge.rb', line 37

def channel_read
  update_status
end

#channel_receivedObject



33
34
35
# File 'lib/goru/routines/bridge.rb', line 33

def channel_received
  update_status
end

#channel_reopenedObject



45
46
47
# File 'lib/goru/routines/bridge.rb', line 45

def channel_reopened
  update_status
end

#ready?Boolean

public

Returns:

  • (Boolean)


20
21
22
# File 'lib/goru/routines/bridge.rb', line 20

def ready?
  @status == :ready
end