class Knj::Thread

This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.

Attributes

data[RW]

Public Class Methods

new(*args) { |*args| ... } click to toggle source

Initializes the thread and passes any given arguments to the thread-block.

Calls superclass method
# File lib/knj/thread.rb, line 6
def initialize(*args)
  raise "No block was given." unless block_given?
  
  super(*args) do
    begin
      yield(*args)
    rescue SystemExit, Interrupt
      raise
    rescue Exception => e
      print "#{Knj::Errors.error_str(e)}\n\n"
    end
  end
  
  @data = {}
end

Public Instance Methods

[](key) click to toggle source

Returns a key from the data-hash.

# File lib/knj/thread.rb, line 23
def [](key)
  return @data[key]
end
[]=(key, value) click to toggle source

Sets a key on the data-hash.

# File lib/knj/thread.rb, line 28
def []=(key, value)
  return @data[key] = value
end