Class: Lich::Common::Watchfor
- Inherits:
-
Object
- Object
- Lich::Common::Watchfor
- Defined in:
- documented/common/watchfor.rb
Overview
Represents a watcher that triggers a block of code when a specified line matches a pattern.
Class Method Summary collapse
-
.clear ⇒ void
private
rubocop:enable Lint/ReturnInVoidContext Clears all watchfor patterns.
Instance Method Summary collapse
-
#initialize(line, theproc = nil) { ... } ⇒ void
constructor
rubocop:disable Lint/ReturnInVoidContext Initializes a new Watchfor instance.
Constructor Details
#initialize(line, theproc = nil) { ... } ⇒ void
rubocop:disable Lint/ReturnInVoidContext Initializes a new Watchfor instance.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'documented/common/watchfor.rb', line 14 def initialize(line, theproc = nil, &block) return nil unless (script = Script.current) if line.is_a?(String) line = Regexp.new(Regexp.escape(line)) elsif !line.is_a?(Regexp) echo 'watchfor: no string or regexp given' return nil end if block.nil? if theproc.respond_to? :call block = theproc else echo 'watchfor: no block or proc given' return nil end end script.watchfor[line] = block end |
Class Method Details
.clear ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
rubocop:enable Lint/ReturnInVoidContext Clears all watchfor patterns.
38 39 40 |
# File 'documented/common/watchfor.rb', line 38 def self.clear script.watchfor = Hash.new end |