class Array

Public Instance Methods

depth() click to toggle source

depth of an array

# File lib/annlat/AnnLat.rb, line 222
def depth
return 0 if self.class != Array
result = 1
self.each do |sub_a|
  if sub_a.class == Array
    dim = sub_a.depth
    result = dim + 1 if dim + 1 > result
  end
end
result
end
to_ltx() click to toggle source
# File lib/annlat/LaRuby.rb, line 222
def to_ltx
  a = map{ |obj| obj.to_ltx.latex }
  LatexList.new(a)
end
to_table() click to toggle source
# File lib/annlat/AnnLat.rb, line 206
def to_table
#  raise "It must be two-dimensional array" unless self.depth==2
  table=Table.new
  self.each_with_index do |row,i|
    table.objects[i]=row
    temp=[]
    row.each do |item|
      temp << get_type(item)
    end
    table.types[i]=temp
  end
  table
end