title: Return object attribute from array of objects in Ruby
body: <p>I am trying to create a new hash out of object attributes from an array of objects. I am using the Amazon API via the ruby aaws gem, and I am having trouble figuring out how to loop through the array that the API returns so that it will only the attributes and not the entire array. When i run the code below, it returns the entire array. </p>
  
  <pre><code>   def self.amazon(search)
      keywords = "#{search}"
      resp = Amazon::AWS.item_search('Books', { 'Title' =&gt; keywords })
      items = resp.item_search_response[0].items[0].item
      items.each do |attribs|
        a = attribs.item_attributes
        @results = []
        @results &lt;&lt; {:label =&gt; "#{a.title.to_s[0,85] unless a.title.nil?}",
                   :value =&gt; "#{a.title.to_s unless a.title.nil?}",
                   :img =&gt; "#{attribs.medium_image.url.to_s unless attribs.medium_image.url.nil?}"""
                  }
  
       end
     end
  </code></pre>
  
  <p>I need to modify the loop, but I am not sure exactly where I am wrong. </p>