#============================================================================== # ■ Array #------------------------------------------------------------------------------ #  配列のクラスです。 #============================================================================== class Array def to_t xdata = nil ydata = nil zdata = nil table = Table.new(self.size) for x in 0...self.size if xdata == nil xdata = self[x].class end if self[x] != xdata print "これじゃ変換できないだろ!" return self end if self[x].is_a?(Array) if self[x].size >= table.ysize table.resize(table.xsize, self[x].size) end for y in 0...self[x].size if ydata == nil ydata = self[x].class end if self[x][y] != ydata print "これじゃ変換できないだろ!" return self end if self[x][y].is_a?(Array) if self[x][y].size >= table.zsize table.resize(table.xsize, table.ysize, self[x][y].size) end for z in 0...self[x][y].size if zdata == nil zdata = self[x][y].class end if self[x][y] != ydata print "これじゃ変換できないだろ!" return self end if self[x][y].is_a?(Array) print "次元が多すぎるだろ!" return self elsif self[x][y][z].is_a?(Fixnum) if self[x][y][z] >= 32768 or x < -32768 print "これじゃ変換できないだろ!" return self end table[x, y, z] = self[x][y][z] else print "これじゃ変換できないだろ!" return self end end elsif self[x][y].is_a?(Fixnum) if self[x][y] >= 32768 or x < -32768 print "これじゃ変換できないだろ!" return self end table[x, y] = self[x][y] else print "これじゃ変換できないだろ!" return self end end elsif self[x].is_a?(Fixnum) if self[x] >= 32768 or x < -32768 print "これじゃ変換できないだろ!" return self end table[x] = self[x] else print "これじゃ変換できないだろ!" return self end end return table end end #============================================================================== # ■ Table #------------------------------------------------------------------------------ #  簡易配列のクラスです。 #============================================================================== class Table def to_a array = [] for i in 0...self.xsize begin self[i, j, 0] array[i] = [] for j in 0...self.ysize array[i][j] = [] for k in 0...self.zsize array[i][j][k] = self[i, j, k] end end rescue ArgumentError begin self[i, 0] array[i] = [] for j in 0...self.ysize array[i][j] = self[i, j] end rescue ArgumentError array[i] = self[i] end end end return array end end