module Util3D
Public Class Methods
check_arg_type(type, instance, nullable = false, array_check = false)
click to toggle source
# File lib/util.rb, line 2 def self.check_arg_type(type, instance, nullable = false, array_check = false) return if(nullable && instance.nil?) if(array_check && instance.kind_of?(Array)) instance.each do |item| check_arg_type(type, item, nullable, array_check) end else unless(instance.kind_of?(type)) raise(ArgumentError::new("type mismatch: #{instance.class} for #{type}")) end end end
check_key_arg(arg, key)
click to toggle source
# File lib/util.rb, line 19 def self.check_key_arg(arg, key) if(!arg.include?(key)) raise(ArgumentError::new("args should be contains: #{key}")) end end
raise_argurment_error(instance)
click to toggle source
# File lib/util.rb, line 15 def self.raise_argurment_error(instance) raise(ArgumentError::new("type mismatch: #{instance.class}")) end