Class: PutsUtils::PutsTable::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/puts_utils/puts_table/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ Formatter

Returns a new instance of Formatter.



8
9
10
11
# File 'lib/puts_utils/puts_table/formatter.rb', line 8

def initialize(table)
  @table = table
  @sizes = {}
end

Instance Attribute Details

#tableObject (readonly)

Returns the value of attribute table.



6
7
8
# File 'lib/puts_utils/puts_table/formatter.rb', line 6

def table
  @table
end

Instance Method Details

#to_sObject



13
14
15
16
17
# File 'lib/puts_utils/puts_table/formatter.rb', line 13

def to_s
  table.rows.map do |values|
    render_row(values)
  end.join("\n")
end