Class: Emit::OutputGuard

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argument, message, action = nil) ⇒ OutputGuard

Returns a new instance of OutputGuard.



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

def initialize(argument, message, action=nil)
  case argument
  when OutputGuard
    @channel_end, @message, @action = argument.channel_end, argument.message, argument.action
  when ChannelEndWrite
    @channel_end, @message, @action = argument, message, action
  when Array
    fail "Wrong number of arguments" unless argument.size == 3
    @channel_end, @message, @action = argument
  else
    fail "Unknown output guard type"
  end

  fail "OutputGuard must have a writing channel end." unless ChannelEndWrite === channel_end
  fail "OutputGuard 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/output_guard.rb', line 3

def action
  @action
end

#channel_endObject (readonly)

Returns the value of attribute channel_end.



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

def channel_end
  @channel_end
end

#messageObject (readonly)

Returns the value of attribute message.



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

def message
  @message
end