Sha256: 5e1c88d8d93b6aa30c2a98c0be2d9c8800a7deb083559e356627ccf15b46ce63

Contents?: true

Size: 577 Bytes

Versions: 4

Compression:

Stored size: 577 Bytes

Contents

# frozen_string_literal: true

module Kaicho
  # A utility module for Kaicho.  Don't touch this stuff!
  module Util
    module_function

    # raise an exception if a type is invalid
    #
    # @param [Class] expected the expected type
    # @param [Instance] got the received type
    # @return [True] this method always returns true or raises an exception
    def check_type(expected, got)
      unless expected === got
        raise(
          TypeError,
          "expected #{expected.name} got #{got}:#{got.class.name}"
        )
      end

      true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kaicho-0.3.1 lib/kaicho/util.rb
kaicho-0.3.0 lib/kaicho/util.rb
kaicho-0.2.2 lib/kaicho/util.rb
kaicho-0.2.0 lib/kaicho/util.rb