Class: Knj::Thread
Overview
This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Returns a key from the data-hash.
-
#[]=(key, value) ⇒ Object
Sets a key on the data-hash.
-
#initialize(*args) ⇒ Thread
constructor
Initializes the thread and passes any given arguments to the thread-block.
Constructor Details
#initialize(*args) ⇒ Thread
Initializes the thread and passes any given arguments to the thread-block.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#data ⇒ Object
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
Returns a key from the data-hash.
23 24 25 |
# File 'lib/knj/thread.rb', line 23 def [](key) return @data[key] end |
#[]=(key, value) ⇒ Object
Sets a key on the data-hash.
28 29 30 |
# File 'lib/knj/thread.rb', line 28 def []=(key, value) return @data[key] = value end |