title: Issues iterating over a hash in Ruby
body: <p>What I'd like to do is pass in a hash of hashes that looks something like this:</p>
  
  <pre><code>input = {
      "configVersion" =&gt; "someVers",
      "box" =&gt; 
      {
          "primary"  =&gt; {
              "ip" =&gt; "192.168.1.1", 
              "host" =&gt; "something"
              },
          "api" =&gt; {
              "live" =&gt; "livekey", 
              "test" =&gt; "testkey"
              }
      }
  }
  </code></pre>
  
  <p>then iterate over it, continuing if the value is another hash, and generating output with it. The result should be something like this:</p>
  
  <pre><code>configVersion = "someVers"
  box.primary.ip = "192.168.1.1"
  box.primary.host = "something"
  </code></pre>
  
  <p>and so on...</p>
  
  <p>I know how to crawl through and continue if the value is a hash, but I'm unsure how to concatenate the whole thing together and pass the value back up. Here is my code:</p>
  
  <pre><code>def crawl(input)
    input.each do |k,v|
      case v
      when Hash
        out &lt; "#{k}."
        crawl(v)
      else
        out &lt; " = '#{v}';"
      end
    end
  end
  </code></pre>
  
  <p>My problem is: where to define <code>out</code> and how to return it all back. I'm very new to Ruby.</p>