class ProtonBot::EventLock

Event lock. Locks current thread until matching event is emitted @!attribute [r] plug

@return [Plug] Plug

@!attribute [r] pattern

@return [Hash<Symbol>] Pattern

Attributes

pattern[R]
plug[R]

Public Class Methods

new(plug, pattern) click to toggle source

@param plug [Plug] @param pattern [Hash<Symbol>]

# File lib/protonbot/event_lock.rb, line 11
def initialize(plug, pattern)
  @plug = plug
  @plug.event_locks << self
  @pattern = pattern
  @unlock = false
  sleep(0.01) until @unlock
end

Public Instance Methods

unlock() click to toggle source

Unlocks current thread @return [NilClass]

# File lib/protonbot/event_lock.rb, line 21
def unlock
  @unlock = true
  nil
end