Class: RTables::Table::PlainTable

Inherits:
RTables::TableBuilder show all
Defined in:
lib/rtables/tables/plaintable.rb

Instance Attribute Summary

Attributes inherited from RTables::TableBuilder

#columns, #rows, #table_content, #table_header

Instance Method Summary collapse

Methods inherited from RTables::TableBuilder

#add_column, #add_row, #column_exist?, #empty?, #initialize, #inspect, #raise_if_empty, #to_s

Constructor Details

This class inherits a constructor from RTables::TableBuilder

Instance Method Details

#renderObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rtables/tables/plaintable.rb', line 4

def render
  raise_if_empty

  lines = []
  i = 0

  @table_content.each do |content|
    @table_header.each do |header|
      lines << "#{header}: #{content[i]}"
      i += 1
    end
    lines << '----'
    i = 0
  end

  lines
end