Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/annlat/AnnLat.rb,
lib/annlat/LaRuby.rb
Instance Method Summary collapse
-
#depth ⇒ Object
depth of an array.
- #to_ltx ⇒ Object
- #to_table ⇒ Object
Instance Method Details
#depth ⇒ Object
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_ltx ⇒ Object
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_table ⇒ Object
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 |