Class: Clio::Layout::Table
- Inherits:
-
Clio::Layout
- Object
- Clio::Layout
- Clio::Layout::Table
- 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
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
Instance Method Summary collapse
- #cell(acell) ⇒ Object
-
#initialize(*rows_of_cells, &block) ⇒ Table
constructor
A new instance of Table.
- #row(*cells, &block) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Clio::Layout
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
#rows ⇒ Object (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_s ⇒ Object
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 |