Commits

Ronny Pfannschmidt  committed cef2b0e

footers and propper last result tracking

  • Participants
  • Parent commits 568cb16

Comments (0)

Files changed (2)

File composeapp/lib/tabular.coffee

 class TableWriter
   constructor: (@send_one, @items, @discriminate) ->
     @buffers = new Array(@items.length)
-    for i in [1..@items.length]
+    for i in [0..@items.length]
       @buffers[i] = new Array()
 
   make_header: (maker) ->
     for item in @items
       maker @sendfunc(item), item
 
+  make_footer: (maker) ->
+    for item in @items
+      maker @sendfunc(item)
+
   sendfunc: (val) ->
     if val == @items[0]
       @send_one
         return
 
   make_rows: (getRow, maker) ->
-    last = {}
+    lasts = for _ in @items
+      {}
     while row = getRow()
       val = @discriminate(row)
-      last = maker @sendfunc(val), row, last
+      index = @items.indexOf(val)
+      lasts[index] = maker @sendfunc(val), row, lasts[index]
 
   finalize: () ->
     for buffer in @buffers

File composeapp/lists.yml

         send '    <td class=incorrect>'
       send '&nbsp\n'
       return val.spec
-
+    
+    tw.make_footer (send) -> send '</table>'
     tw.finalize()
     return