Sha256: 65209ac47d9d27419cc68996e836b036745f8baa524e8f434b63db5fc5713df8
Contents?: true
Size: 881 Bytes
Versions: 3
Compression:
Stored size: 881 Bytes
Contents
module Diagnostics module Data class Table < Struct.new(:value) def html "".tap do |s| s.extend(HTMLMethods) s.wrap :table do s.wrap :tr do value.keys.each do |k| s.wrap :th do s << k.to_s end end end rows.transpose.each do |v| s.wrap :tr do v.each do |td| s.wrap :td do s << td.to_s end end end end end end end module HTMLMethods def wrap(tag) concat "<#{tag}>" yield if block_given? concat "</#{tag}>" end end private def rows value.values.map {|v| [v].flatten } end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
diagnostics-0.0.4 | lib/diagnostics/data/table.rb |
diagnostics-0.0.3 | lib/diagnostics/data/table.rb |
diagnostics-0.0.2 | lib/diagnostics/data/table.rb |