Class: Emit::InputGuard

Inherits:
Object
  • Object
show all
Defined in:
lib/emit/input_guard.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argument, action = ->(msg) {msg}) ⇒ InputGuard

Returns a new instance of InputGuard.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/emit/input_guard.rb', line 5

def initialize(argument, action=->(msg) {msg})
  case argument
  when InputGuard
    @channel_end, @action = argument.channel_end, argument.action
  when ChannelEndRead
    @channel_end, @action = argument, action
  when Array
    fail "Wrong number of arguments" unless argument.size == 2
    @channel_end, @action = argument
  else
    fail "Unknown input guard type"
  end

  fail "InputGuard must have a reading channel end." unless ChannelEndRead === @channel_end
  fail "InputGuard action cannot be nil" if @action.nil?
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



3
4
5
# File 'lib/emit/input_guard.rb', line 3

def action
  @action
end

#channel_endObject (readonly)

Returns the value of attribute channel_end.



3
4
5
# File 'lib/emit/input_guard.rb', line 3

def channel_end
  @channel_end
end