Class: Diagnostics::Data::Table

Inherits:
Struct
  • Object
show all
Defined in:
lib/diagnostics/data/table.rb

Defined Under Namespace

Modules: HTMLMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



3
4
5
# File 'lib/diagnostics/data/table.rb', line 3

def value
  @value
end

Instance Method Details

#htmlObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/diagnostics/data/table.rb', line 5

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