Class: Amberletters::ExitTrigger

Inherits:
Trigger
  • Object
show all
Defined in:
lib/amberletters.rb

Instance Attribute Summary collapse

Attributes inherited from Trigger

#exclusive, #interruption, #logger, #options, #time_to_live

Instance Method Summary collapse

Constructor Details

#initialize(pattern = 0, options = {}, &block) ⇒ ExitTrigger

Returns a new instance of ExitTrigger.



184
185
186
187
# File 'lib/amberletters.rb', line 184

def initialize(pattern=0, options={}, &block)
  super(options, &block)
  @pattern = pattern
end

Instance Attribute Details

#patternObject (readonly)

Returns the value of attribute pattern.



182
183
184
# File 'lib/amberletters.rb', line 182

def pattern
  @pattern
end

Instance Method Details

#call(process) ⇒ Object



189
190
191
192
193
194
195
196
# File 'lib/amberletters.rb', line 189

def call(process)
  if process.status && pattern === process.status.exitstatus
    @block.call(self, process, process.status)
    true
  else
    false
  end
end

#to_sObject



198
199
200
# File 'lib/amberletters.rb', line 198

def to_s
  "exit with status #{pattern}"
end