Ruby 配列に格納されているデータを使用して、以下のようなテーブルを作成したいと考えています。
______________________________________________________________
| BUILD | PLATFORM | CATEGORY |
|______________|________________|____________________________|
| | | IP |
| | 8k |____________________________|
| | | UMTS |
| |________________|____________________________|
| 10.0.1.50 | | IP |
| | |____________________________|
| | | UMTS |
| | 9k |____________________________|
| | | Stability |
|______________|________________|____________________________|
| | | IP |
| 10.0.1.51 | 8k |____________________________|
| | | UMTS |
|______________|________________|____________________________|
| | | IP |
| 11.0.1.50 | 9k |____________________________|
| | | UMTS |
|______________|________________|____________________________|
3 つの配列に次のデータがあります。
Arr1
-------------------
row[0] : row[1]
-------------------
11.0.1.50 : 2
10.0.1.51 : 2
10.0.1.50 : 5
Arr2
---------------------------
row[0] : row[1] : row[2]
---------------------------
11.0.1.50 : 9k : 2
10.0.1.50 : 9k : 3
10.0.1.51 : 8k : 2
10.0.1.50 : 8k : 2
Arr3
-------------------------------
row[0] : row[1] : row[2]
-------------------------------
10.0.1.50 : 8k : IP
10.0.1.50 : 8k : UMTS
10.0.1.51 : 8k : IP
10.0.1.51 : 8k : UMTS
10.0.1.50 : 9k : IP
10.0.1.50 : 9k : Stability
10.0.1.50 : 9k : UMTS
11.0.1.50 : 9k : IP
11.0.1.50 : 9k : UMTS
配列内のこれらすべての数値は、基本的に、その特定のエントリに必要な行スパンの数を示します。
Railsビューでいくつかのコードを書きましたが、目的の出力が得られないようです:
<% @l1_reg.each_with_index do |row1, index1| %>
<table>
<tr>
<!-- Build -->
<td rowspan='<%= row1[1] %>'><strong><%= row1[0] %></strong></td>
<% @l2_reg.each_with_index do |row2, index2| %>
<% if ((row2[0].to_s == row1[0].to_s) %>
<!-- Platform -->
<td rowspan='<%= row2[1] %>'><strong><%= row2[0] %></strong</td>
<% @l3_reg.each_with_index do |row3, index3| %>
<% if ((row3[0].to_s == row2[0].to_s) && (row3[1].to_s == row2[1].to_s)) %>
<!-- Category -->
<td><%= row3[2] %></td>
<% end %>
<% end %>
<% end %>
<% end %>
</tr>
</table>
<% end %>