Class: Dotsync::TableRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/dotsync/utils/table_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows:, headings: nil) ⇒ TableRenderer

Returns a new instance of TableRenderer.



9
10
11
12
# File 'lib/dotsync/utils/table_renderer.rb', line 9

def initialize(rows:, headings: nil)
  @rows = rows
  @headings = headings
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



7
8
9
# File 'lib/dotsync/utils/table_renderer.rb', line 7

def rows
  @rows
end

Instance Method Details

#renderObject



14
15
16
17
18
# File 'lib/dotsync/utils/table_renderer.rb', line 14

def render
  options = { rows: @rows }
  options[:headings] = @headings if @headings
  Terminal::Table.new(**options).to_s
end