Commits

Ronny Pfannschmidt committed 5b16ba7

sendfunc abstraction

  • Participants
  • Parent commits fcd4aa1

Comments (0)

Files changed (2)

File composeapp/lib/tabular.coffee

       @buffers[i] = new Array()
 
   make_header: (maker) ->
-    @header_maker = maker
-    maker @send_one, @items[0]
+    for item in @items
+      maker @sendfunc(item), item
+
+  sendfunc: (val) ->
+    if val == @items[0]
+      @send_one
+    else
+      index = @items.indexOf(val)
+      (data) =>
+        @buffers[index].push(data)
+        return
 
   make_rows: (getRow, maker) ->
+    last = {}
     while row = getRow()
-      maker @send_one, row
+      val = @discriminate(row)
+      last = maker @sendfunc(val), row, last
 
   finalize: () ->
     for buffer in @buffers
       buffer.forEach @send_one
+    return
 
 exports.TableWriter = TableWriter

File composeapp/lists.yml

       for p in baseinfo.axis.population
         send '    <th>' + p + '\n'
     last = {}
-    tw.make_rows getRow, (send, row) ->
+    tw.make_rows getRow, (send, row, last) ->
       val = row.value
-      if val.spec['height-weight'] != hw
-        return
       if last.generations != val.spec.generations
         send '  <tr><th>' + val.spec.generations + '\n'
       if val.correct
       else
         send '    <td class=incorrect>'
       send '&nbsp\n'
-      last = val.spec || {}
+      return val.spec
+
+    tw.finalize()
     return