title: Class (Type) checking
body: <p>Is there a good library (preferably gem) for doing class checking of an object? The difficult part is that I not only want to check the type of a simple object but want to go inside an array or a hash, if any, and check the classes of its components. For example, if I have an object:</p>
  
  <pre><code>object = [
    "some string",
    4732841,
    [
      "another string",
      {:some_symbol =&gt; [1, 2, 3]}
    ],
  ]
  </code></pre>
  
  <p>I want to be able to check with various levels of detail, and if there is class mismatch, then I want it to return the position in some reasonable way. I don't yet have a clear idea of how the error (class mismatch) format should be, but something like this:</p>
  
  <pre><code>object.class_check(Array) # =&gt; nil (`nil` will mean the class matches)
  object.class_check([String, Fixnum, Array]) # =&gt; nil
  object.class_check([String, Integer, Array]) # =&gt; nil
  object.class_check([String, String, Array]) # =&gt; [1] (This indicates the position of class mismatch)
  object.class_check([String, Fixnum, [Symbol, Hash]) # =&gt; [2,0] (meaning type mismatch at object[2][0])
  </code></pre>
  
  <p>If there is no such library, can someone (show me the direction in which I should) implement this? Probably, I should use <code>kind_of?</code> and recursive definition.</p>