My Ruby Code: How can I improve? (Java to Ruby guy)
Greetings, 

I get the feeling that I'm using ruby in an ugly way and possibly missing out on tonnes of useful features. I was wondering if anyone could point out a cleaner better way to write my code which is pasted here. The code itself simply scrapes some data from yelp and processes it into a json format. The reason I'm not using hash.to_json is because it throws some sort of stack error which I can only assume is due to the hash being too large (It's not particularly large). 

Response object = a hash
text = the output which saves to file
Anyways guidance appreciated. 


    def mineLocation
    
      client = Yelp::Client.new
      request = Yelp::Review::Request::GeoPoint.new(:latitude=>13.3125,:longitude => -6.2468,:yws_id => 'nicetry')
      response = client.search(request) 
      response['businesses'].length.times do |businessEntry|
        text =""
         response['businesses'][businessEntry].each { |key, value|
            if value.class == Array 
              value.length.times { |arrayEntry|
                text+= "\"#{key}\":["
                 value[arrayEntry].each { |arrayKey,arrayValue|
                  text+= "{\"#{arrayKey}\":\"#{arrayValue}\"},"
                 }
                 text+="]"   
              }
            else 
                  text+="\"#{arrayKey}\":\"#{arrayValue}\"," 
            end
           }
      end
     end
My Ruby Code: How can I improve? (Java to Ruby guy)
===

Greetings, 

I get the feeling that I'm using ruby in an ugly way and possibly missing out on tonnes of useful features. I was wondering if anyone could point out a cleaner better way to write my code which is pasted here. The code itself simply scrapes some data from yelp and processes it into a json format. The reason I'm not using hash.to_json is because it throws some sort of stack error which I can only assume is due to the hash being too large (It's not particularly large). 

Response object = a hash
text = the output which saves to file
Anyways guidance appreciated. 


    def mineLocation
    
      client = Yelp::Client.new
      request = Yelp::Review::Request::GeoPoint.new(:latitude=>13.3125,:longitude => -6.2468,:yws_id => 'nicetry')
      response = client.search(request) 
      response['businesses'].length.times do |businessEntry|
        text =""
         response['businesses'][businessEntry].each { |key, value|
            if value.class == Array 
              value.length.times { |arrayEntry|
                text+= "\"#{key}\":["
                 value[arrayEntry].each { |arrayKey,arrayValue|
                  text+= "{\"#{arrayKey}\":\"#{arrayValue}\"},"
                 }
                 text+="]"   
              }
            else 
                  text+="\"#{arrayKey}\":\"#{arrayValue}\"," 
            end
           }
      end
     end