Exception: ArgumentError

Inherits:
Exception
  • Object
show all
Defined in:
lib/parallelpipes.rb

Overview

class IO

def non_blocking_gets(timeout=0.01) t = Thread.ppipe_new= Thread.current; th = nil; th = gets sleep timeout; t.kill; return t end end

Class Method Summary collapse

Class Method Details

.check(*values, &block) ⇒ Object



318
319
320
321
322
323
324
325
326
327
# File 'lib/parallelpipes.rb', line 318

def self.check(*values, &block)
  values.each do |name, value, test_data|
    if block
      raise new("#{name} failed argument correctness test (value given was '#{value.inspect}')") unless yield(value, test_data)
    else
      is_array = test_data.class == Array
      raise new("#{name} was of class #{value.class} instead of #{test_data.inspect} (value given was #{value.inspect})") unless (is_array ? test_data.include?(value.class) : value.class == test_data)
    end
  end
end