-4
如何格式化列我有一個數組內的Ruby數組看起來象下面這樣:所以他們行使用Ruby
更多的數據信息是這裏https://gist.github.com/theCrab/6064789
列標題是風格,顏色, 大小,降序,數量,min_qty,req_qty,個root_sku,offset_size
[ ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/2SHORT LEG", "28\" W", "29\"LEG STD MENS TROUSER", -10, 4, 14, "00001955", 1], ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/2SHORT LEG", "30\" W", "29\"LEG STD MENS TROUSER", -14, 6, 20, "00001955", 2], ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/2SHORT LEG", "32\" W", "29\"LEG STD MENS TROUSER", -29, 6, 35, "00001955", 3], ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/3REG LEG", "28\" W", "31\"LEG STD MENS TROUSER", 0, 3, 3, "00001976", 1], ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/3REG LEG", "30\" W", "31\"LEG STD MENS TROUSER", -12, 5, 17, "00001976", 2], ["UD/BOYS-TR/SENIOR/STANDARD", "*BLACK/3REG LEG", "32\" W", "31\"LEG STD MENS TROUSER", -6, 6, 12, "00001976", 3] ]
我想打印一個很好的格式化的表格看起來象下面這樣:
style | colour | size | desc | qty | min_qty | req_qty | root_sku
-----------------------------------------------------------------
standd| red | 28 W | N/a | 4 | 5 | 1 | 00001955
| | 30 W | N/a | 9 | 5 | 4 | 00001955
| | 36 W | N/a | 10 | 5 | 5 | 00001955
| blue | 28 W | N/a | 4 | 5 | 1 | 00001955
| | 30 W | N/a | 9 | 5 | 4 | 00001955
| | 36 W | N/a | 10 | 5 | 5 | 00001955
fitted| red/blu| 28 W | N/a | 4 | 5 | 1 | 00001954
| | 30 W | N/a | 9 | 5 | 4 | 00001954
| | 36 W | N/a | 10 | 5 | 5 | 00001954
| blue | 28 W | N/a | 4 | 5 | 1 | 00001954
| | 30 W | N/a | 9 | 5 | 4 | 00001954
| | 36 W | N/a | 10 | 5 | 5 | 00001954
我怎樣才能最好通過陣列運行,並完成這一壯舉?
你嘗試過什麼? – Romoku
這個任務有很多寶石。你應該用'ruby gem print table'或類似的東西搜索網頁... –
你有沒有想過把這些數據轉儲到CSV中?這裏是[Ruby中CSV類的文檔](http://ruby-doc.org/stdlib-1.9.3/libdoc/csv/rdoc/CSV.html)。 – Batkins