Class: Numo::NArray

Inherits:
Object
  • Object
show all
Defined in:
lib/rubydown.rb

Instance Method Summary collapse

Instance Method Details

#to_htmlObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rubydown.rb', line 12

def to_html
  case ndim
  when 2
    rows = self.to_a.map do |row|
      elems = row.map do |elem|
        "<td>#{elem}</td>"
      end
      "<tr>#{elems.join}</tr>"
    end
    "<table>#{rows.join}</table>"
  when 1
    cols = self.to_a.map do |elem|
      "<td>#{elem}</td>"
    end
    "<table><tr>#{cols.join}</tr></table>"
  else
    inspect
  end
end