7.5.3. Metody modulu StrongTyping

StrongTyping::expect(par0, Type0[, par1, Type1[,...parN, TypeN]])

Kontrola typu parametrů. Jako typ je možno použít název třídy nebo název modulu. Pokud bude alespoň jeden parametr nesprávného typu, metoda vyvolá výjimku typu StrongTyping::ArgumentTypeError

overload(args, [Module0[, Module1[,...ModuleN]]]) { | o0, o1,..oN | }

FIXME: Call the block with 'args' if they match the pattern Module0..ModuleN. The block should _always_ call return at the end.

overload_exception(args, [Module0[,...ModuleN]]]) { | o0, o1,..oN | }

FIXME: This acts identically to overload(), except the case specified is considered invalid, and thus not returned by get_arg_types(). It is expected that the specified block will throw an exception.

overload_default(args), overload_error(args)

FIXME: Raise OverloadError. This should _always_ be called after the last overload() block. In addition to raising the exception, it aids in checking parameters. As of 2.0, the overload_error name is deprecated; use overload_default.

get_arg_types(Method)

FIXME: Return an array of parameter templates. This is an array of arrays, and will have multiple indices for functions using multiple overload() blocks.

verify_args_for(method, args)

FIXME: Verify the method 'method' will accept the arguments in array 'args', returning a boolean result.

Třídy reprezentující výjimky

StrongTyping::ArgumentTypeError < ArgumentError

FIXME: This exception is raised by expect() if the arguments do not match the expected types.

StrongTyping::OverloadError < ArgumentTypeError

FIXME: This exception is raised by overload_default() if no overload() template matches the given arguments.

Licence Creative Commons
Tento dokument Ruby, jehož autorem je Radek Hnilica, podléhá licenci Creative Commons Uveďte autora-Nevyužívejte dílo komerčně-Zachovejte licenci 3.0 Česká republika .