Module: Jubatus::Common

Defined Under Namespace

Classes: Client, ClientBase, Datum, InterfaceMismatch, MessageStringGenerator, TBool, TDatum, TEnum, TFloat, TInt, TList, TMap, TNullable, TObject, TPrimitive, TRaw, TString, TTuple, TUserDef, TypeError, TypeMismatch, UnknownMethod, ValueError

Class Method Summary collapse

Class Method Details

.check_type(value, typ) ⇒ Object


7
8
9
10
11
# File 'lib/jubatus/common/types.rb', line 7

def self.check_type(value, typ)
  if not (typ === value)
    raise TypeError, "type %s is expected, but %s is given" % [typ, value.class]
  end
end

.check_types(value, types) ⇒ Object

Raises:


13
14
15
16
17
18
19
# File 'lib/jubatus/common/types.rb', line 13

def self.check_types(value, types)
  types.each do |t|
    return if t === value
  end
  t = types.map { |t| t.to_s }.join(", ")
  raise TypeError, "type %s is expected, but %s is given" % [t, value.class]
end