Sha256: fa039e050f368f81492b9ab05b379f17908200d95a3fe078c9978e2bb343ebd4

Contents?: true

Size: 705 Bytes

Versions: 11

Compression:

Stored size: 705 Bytes

Contents

#This class behaves like a normal thread - but it shows error-messages and tracebacks. Normal threads dont do that.
class Knj::Thread < Thread
  attr_accessor :data
  
  #Initializes the thread and passes any given arguments to the thread-block.
  def initialize(*args)
    raise "No block was given." unless block_given?
    
    super(*args) do
      begin
        yield(*args)
      rescue SystemExit
        exit
      rescue => e
        print "#{Knj::Errors.error_str(e)}\n\n"
      end
    end
    
    @data = {}
  end
  
  #Returns a key from the data-hash.
  def [](key)
    return @data[key]
  end
  
  #Sets a key on the data-hash.
  def []=(key, value)
    return @data[key] = value
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
knjrbfw-0.0.52 lib/knj/thread.rb
knjrbfw-0.0.51 lib/knj/thread.rb
knjrbfw-0.0.50 lib/knj/thread.rb
knjrbfw-0.0.49 lib/knj/thread.rb
knjrbfw-0.0.48 lib/knj/thread.rb
knjrbfw-0.0.47 lib/knj/thread.rb
knjrbfw-0.0.46 lib/knj/thread.rb
knjrbfw-0.0.45 lib/knj/thread.rb
knjrbfw-0.0.44 lib/knj/thread.rb
knjrbfw-0.0.43 lib/knj/thread.rb
knjrbfw-0.0.42 lib/knj/thread.rb