Class: Clio::Layout::Table

Inherits:
Clio::Layout show all
Defined in:
lib/clio/layout/table.rb

Overview

Table

Currently the table layout class is very simplistic. Ultimately it will support headers, footers, and a varity of border options.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Clio::Layout

#screen_width

Constructor Details

#initialize(*rows_of_cells, &block) ⇒ Table

Returns a new instance of Table.



17
18
19
# File 'lib/clio/layout/table.rb', line 17

def initialize(*rows_of_cells, &block)
  @rows = rows_of_cells
end

Instance Attribute Details

#rowsObject (readonly)

Returns the value of attribute rows.



15
16
17
# File 'lib/clio/layout/table.rb', line 15

def rows
  @rows
end

Instance Method Details

#cell(acell) ⇒ Object



26
27
28
# File 'lib/clio/layout/table.rb', line 26

def cell(acell)
  (@rows.last ||= []) << acell
end

#row(*cells, &block) ⇒ Object



21
22
23
24
# File 'lib/clio/layout/table.rb', line 21

def row(*cells, &block)
  @rows << cells
  instance_eval(&block)
end

#to_sObject



30
31
32
33
34
35
# File 'lib/clio/layout/table.rb', line 30

def to_s
  #screen_width
  rows.collect{ |cells|
    cells.join(' ')
  }.join("\n")
end