Module: Kaicho::Util

Defined in:
lib/kaicho/util.rb

Overview

A utility module for Kaicho. Don’t touch this stuff!

Class Method Summary collapse

Class Method Details

.check_type(expected, got) ⇒ True

raise an exception if a type is invalid

Parameters:

  • expected (Class)

    the expected type

  • got (Instance)

    the received type

Returns:

  • (True)

    this method always returns true or raises an exception



13
14
15
16
17
18
19
20
21
22
# File 'lib/kaicho/util.rb', line 13

def check_type(expected, got)
  unless expected === got
    raise(
      TypeError,
      "expected #{expected.name} got #{got}:#{got.class.name}"
    )
  end

  true
end