title: How can I implement a chain method for my class?
body: <p>I'm working with a string that has to be converted to a 2 dimensional array:</p>
  
  <pre><code>rows = [['1', '2'], ['10', '20']]
  </code></pre>
  
  <p>I need those values as integers instead of strings. I can iterate through them and then do <code>map</code>, like:</p>
  
  <pre><code>rows.each {|row| row.map!(&amp;:to_i)}
  </code></pre>
  
  <p>I was trying to create a <code>to_i</code> method that could be chainable, so I can run <code>rows.to_i</code>.</p>
  
  <pre><code>def to_i
    each do |nested|
      nested.map!(&amp;:to_i)
    end
  end
  </code></pre>
  
  <p>This unsurprisingly fails:</p>
  
  <pre><code>NoMethodError: undefined method `to_i' for [["1", "2"], ["10", "20"]]:Array
  </code></pre>
  
  <p>since <code>Array</code> doesn't implement the method. Besides monkey patching the <code>Array</code> class, is there a proper or more rubier way to do it?</p>
  
  <p>The other alternative is doing:</p>
  
  <pre><code>def ary_to_i array
    array.each do |nested|
      nested.map!(&amp;:to_i)
    end
  end
  </code></pre>
  
  <p>but I found the method call <code>ary_to_i(rows)</code> confusing.</p>