lib/nyaplot/data.rb in nyaplot-0.1.0 vs lib/nyaplot/data.rb in nyaplot-0.1.1
- old
+ new
@@ -133,12 +133,16 @@
block.call(row)
end
end
def to_html(threshold = 15)
- html = '<table><tr>'
- @rows[0].each {|key, val| html.concat('<th>' + key.to_s + '</th>')}
- html += '</tr>'
+ html = '<table>'
+
+ unless @rows[0].nil?
+ html += '<tr>'
+ @rows[0].each {|key, val| html.concat('<th>' + key.to_s + '</th>')}
+ html += '</tr>'
+ end
@rows.each_with_index do |row, i|
next if i > threshold && i < @rows.length-1
html += '<tr>'
row.each{|key, val| html.concat('<td>' + val.to_s + '</td>')}