Sha256: 6c5801b87c4f2b84c2a78238c08b39fec548321d9fd878397a8e602bb4aeac9e
Contents?: true
Size: 959 Bytes
Versions: 8
Compression:
Stored size: 959 Bytes
Contents
require 'hyperion/aux/bug_error' class Hyperion class Util def self.nil_if_error begin yield rescue StandardError return nil end end def self.guard_param(value, what, expected_type=nil, &pred) pred ||= proc { |x| x.is_a?(expected_type) } pred.call(value) or fail BugError, "You passed me #{value.inspect}, which is not #{what}" end # reimplement callcc because ruby has deprecated it def self.callcc() in_scope = true cont = proc do |retval| unless in_scope raise "Cannot invoke this continuation. Control has left this continuation's scope." end raise CallCcError.new(retval) end yield(cont) rescue CallCcError => e e.retval ensure in_scope = false end class CallCcError < RuntimeError attr_accessor :retval def initialize(retval) @retval = retval end end end end
Version data entries
8 entries across 8 versions & 1 rubygems