Class: Kuby::Utils::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/utils/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(headers, rows) ⇒ Table

Returns a new instance of Table.



6
7
8
9
# File 'lib/kuby/utils/table.rb', line 6

def initialize(headers, rows)
  @headers = headers
  @rows = rows
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/kuby/utils/table.rb', line 4

def headers
  @headers
end

#rowsObject (readonly)

Returns the value of attribute rows.



4
5
6
# File 'lib/kuby/utils/table.rb', line 4

def rows
  @rows
end

Instance Method Details

#to_sObject



11
12
13
# File 'lib/kuby/utils/table.rb', line 11

def to_s
  [headers, *rows].map { |vals| make_row(vals) }.join("\n")
end