Module: Term
Overview
Example usage:
puts Term::Table[ (1..100).to_a ].horizontally #=> prints all the numbers, ordered across rows
puts Term::Table[ (1..100).to_a ].vertically #=> prints all the numbers, ordered across columns
puts Term::Table[ [[1,2], [3,4]] ] #=> prints the table that was supplied
Term::Table.new do |t|
t.row [...]
t.rows[5] = [...]
t.rows << [...]
t.col []
end.to_s
table.compact.to_s #=> minimize the table's columns
Defined Under Namespace
Instance Attribute Summary collapse
-
#wrap ⇒ Object
Returns the value of attribute wrap.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Instance Method Summary collapse
- #clear ⇒ Object
- #color(fore, back = nil) ⇒ Object
- #goto(x, y) ⇒ Object
- #height ⇒ Object
- #pos ⇒ Object
- #puts(s) ⇒ Object
-
#size ⇒ Object
Return the [width,height] of the terminal.
- #width ⇒ Object
Instance Attribute Details
#wrap ⇒ Object
Returns the value of attribute wrap.
26 27 28 |
# File 'lib/epitools/term.rb', line 26 def wrap @wrap end |
#x ⇒ Object
Returns the value of attribute x.
26 27 28 |
# File 'lib/epitools/term.rb', line 26 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
26 27 28 |
# File 'lib/epitools/term.rb', line 26 def y @y end |
Instance Method Details
#clear ⇒ Object
40 41 42 |
# File 'lib/epitools/term.rb', line 40 def clear print "\e[H\e[J" end |
#color(fore, back = nil) ⇒ Object
44 45 46 47 |
# File 'lib/epitools/term.rb', line 44 def color(fore, back=nil) @fore = fore @back = back if back end |
#goto(x, y) ⇒ Object
37 |
# File 'lib/epitools/term.rb', line 37 def goto(x,y); @x, @y = x, y; end |
#height ⇒ Object
36 |
# File 'lib/epitools/term.rb', line 36 def height; size[1]; end |
#pos ⇒ Object
38 |
# File 'lib/epitools/term.rb', line 38 def pos; [@x, @y]; end |
#puts(s) ⇒ Object
49 50 51 |
# File 'lib/epitools/term.rb', line 49 def puts(s) # some curses shit end |
#size ⇒ Object
Return the [width,height] of the terminal.
31 32 33 |
# File 'lib/epitools/term.rb', line 31 def size STDIN.winsize.reverse end |
#width ⇒ Object
35 |
# File 'lib/epitools/term.rb', line 35 def width; size[0]; end |