Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing a Ruby Array
    text
    copied!<p>I am new to Ruby as probably everyone here knows by now :) I have a query to some service and I get back an array. When I run this code</p> <pre><code>@query_result.each do |test| puts test end </code></pre> <p>I get exactly this output</p> <p><code>["names", ["s", "label"]] ["values", [["&lt;http://www.udfr.org/test-instance#PDF-1&gt;", "\"Acrobat PDF 1.0 - Portable Document Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#BroadcastWave&gt;", "\"Broadcast WAVE\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#PNG-1&gt;", "\"Portable Network Graphics\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#PNG-1-1&gt;", "\"Portable Network Graphics\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#GIF-1989a&gt;", "\"Graphics Interchange Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#TIFF-4&gt;", "\"Tagged Image File Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#TIFF-6&gt;", "\"Tagged Image File Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#BroadcastWave-1&gt;", "\"Broadcast WAVE\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#PNG-1-2&gt;", "\"Portable Network Graphics\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#TIFF-3&gt;", "\"Tagged Image File Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#TIFF-5&gt;", "\"Tagged Image File Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#AVI-Generic&gt;", "\"Audio/Video Interleaved Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#GIF-1987a&gt;", "\"Graphics Interchange Format\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#WaveformAudio&gt;", "\"Waveform Audio\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#BroadcastWave-1&gt;", "\"Broadcast WAVE\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"], ["&lt;http://www.udfr.org/test-instance#BroadcastWave&gt;", "\"Broadcast WAVE\"^^&lt;http://www.w3.org/2001/XMLSchema#string&gt;"]]]</code></p> <p>I know it is cryptic, but basically I just need to extract the values in these:</p> <pre><code>names s label values </code></pre> <p>What would be the code to get the actual values of the columns from the array?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload