Class: Knj::Thread

Inherits:
Thread show all
Defined in:
lib/knj/thread.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Thread

Returns a new instance of Thread.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/knj/thread.rb', line 5

def initialize(*args)
  @data = {}
  raise "No block was given." if !block_given?
  
  super(*args) do
    begin
      yield(*args)
    rescue SystemExit
      exit
    rescue Exception => e
      print Knj::Errors.error_str(e)
    end
  end
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



3
4
5
# File 'lib/knj/thread.rb', line 3

def data
  @data
end

Instance Method Details

#[](key) ⇒ Object



20
21
22
# File 'lib/knj/thread.rb', line 20

def [](key)
  return @data[key]
end

#[]=(key, value) ⇒ Object



24
25
26
# File 'lib/knj/thread.rb', line 24

def []=(key, value)
  return @data[key] = value
end