Class: ImageOptim::Table

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

Overview

Handy class for pretty printing a table in the terminal. This is very simple, switch to Terminal Table, Table Tennis or similar if we need more.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows) ⇒ Table

Returns a new instance of Table.



9
10
11
# File 'lib/image_optim/table.rb', line 9

def initialize(rows)
  @rows = rows
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



7
8
9
# File 'lib/image_optim/table.rb', line 7

def rows
  @rows
end

Instance Method Details

#write(io) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/image_optim/table.rb', line 13

def write(io)
  io.puts render_row(columns)
  io.puts render_sep
  rows.each do |row|
    io.puts render_row(row.values)
  end
end