Save data rewrite & Game module (#91)

This commit is contained in:
Joni Savolainen
2021-02-28 23:26:16 +02:00
committed by GitHub
parent a112a21a87
commit 9c2b6e943b
15 changed files with 1038 additions and 342 deletions

View File

@@ -2,13 +2,13 @@
module Kernel
private
# Used to check whether values are of a given class or respond to a method.
# Used to check whether method arguments are of a given class or respond to a method.
# @param value_pairs [Hash{Object => Class, Array<Class>, Symbol}] value pairs to validate
# @example Validate a class or method
# validate foo => Integer, baz => :to_s # raises an error if foo is not an Integer or if baz doesn't implement #to_s
# @example Validate a class from an array
# validate foo => [Sprite, Bitmap, Viewport] # raises an error if foo isn't a Sprite, Bitmap or Viewport
# @raise [ArgumentError] raised if validation fails
# @raise [ArgumentError] if validation fails
def validate(value_pairs)
unless value_pairs.is_a?(Hash)
raise ArgumentError, "Non-hash argument #{value_pairs.inspect} passed into validate."