Top Level Namespace
Defined Under Namespace
Modules: Gosling, ObjectCache, Snow Classes: MatrixCache, Object, VectorCache
Instance Method Summary collapse
-
#boolean_check(obj) ⇒ Object
Raises an ArgumentError unless the object is truthy.
-
#type_check(obj, type) ⇒ Object
Raises an ArgumentError unless the object is of the specified type.
-
#types_check(obj, *types) ⇒ Object
Raises an ArgumentError unless the object is one of the listed types.
Instance Method Details
#boolean_check(obj) ⇒ Object
Raises an ArgumentError unless the object is truthy.
18 19 20 |
# File 'lib/gosling/utils.rb', line 18 def boolean_check(obj) raise ArgumentError.new("Expected true or false, but received #{obj.inspect}!") unless [true, false].include?(obj) end |
#type_check(obj, type) ⇒ Object
Raises an ArgumentError unless the object is of the specified type.
4 5 6 |
# File 'lib/gosling/utils.rb', line 4 def type_check(obj, type) raise ArgumentError.new("Expected #{type}, but received #{obj.inspect}!") unless obj.is_a?(type) end |
#types_check(obj, *types) ⇒ Object
Raises an ArgumentError unless the object is one of the listed types.
11 12 13 |
# File 'lib/gosling/utils.rb', line 11 def types_check(obj, *types) raise ArgumentError.new("Expected one of #{types.inspect}, but received #{obj.inspect}!") unless types.any? { |type| obj.is_a?(type) } end |