Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/annlat/AnnLat.rb,
lib/annlat/LaRuby.rb

Instance Method Summary collapse

Instance Method Details

#depthObject

depth of an array



222
223
224
225
226
227
228
229
230
231
232
# 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_ltxObject



222
223
224
225
# File 'lib/annlat/LaRuby.rb', line 222

def to_ltx
  a = map{ |obj| obj.to_ltx.latex }
  LatexList.new(a)
end

#to_tableObject



206
207
208
209
210
211
212
213
214
215
216
217
218
# 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