Class: AsciiParadise::AsciiTable::Row
- Inherits:
-
Object
- Object
- AsciiParadise::AsciiTable::Row
- Defined in:
- lib/ascii_paradise/asciitable/row.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#[](i) ⇒ Object
# === [] ========================================================================= #.
-
#add_cell(i) ⇒ Object
(also: #<<)
# === add_cell ========================================================================= #.
-
#cells? ⇒ Boolean
(also: #cells)
# === cells? ========================================================================= #.
-
#height ⇒ Object
(also: #height?)
# === height ========================================================================= #.
-
#initialize(table, array = []) ⇒ Row
constructor
# === initialize.
-
#render ⇒ Object
# === render ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#table? ⇒ Boolean
(also: #table)
# === table? ========================================================================= #.
Constructor Details
Instance Method Details
#[](i) ⇒ Object
#
[]
#
100 101 102 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 100 def [](i) cells[i] end |
#add_cell(i) ⇒ Object Also known as: <<
#
add_cell
#
46 47 48 49 50 51 52 53 54 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 46 def add_cell(i) = i.is_a?(Hash) ? i : {:value => i} cell = Cell.new(.merge(:index => @cell_index, :table => @table)) # ======================================================================= # # The next variables are Integers. # ======================================================================= # @cell_index += cell.colspan # Count up the cell index here. @cells << cell end |
#cells? ⇒ Boolean Also known as: cells
#
cells?
#
66 67 68 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 66 def cells? @cells end |
#height ⇒ Object Also known as: height?
#
height
#
59 60 61 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 59 def height cells.map { |c| c.lines.count }.max end |
#render ⇒ Object
#
render
#
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 73 def render # ======================================================================= # # Obtain a pointer towards the horizontal character, which is usually # '-'. # ======================================================================= # horizontal_token = @table.style.border_y # ======================================================================= # # Next we check whether to colourize this. # ======================================================================= # if AsciiTable.use_colours? horizontal_token = Colours.send( AsciiParadise::AsciiTable.use_which_colours?, horizontal_token ) end array = (0...height).to_a array.map! { |line| horizontal_token + cells.map { |cell| cell.render(line) }.join(horizontal_token) + horizontal_token } result = array.join("\n") return result end |
#reset ⇒ Object
#
reset
#
31 32 33 34 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 31 def reset @cells = [] @cell_index = 0 end |
#table? ⇒ Boolean Also known as: table
#
table?
#
39 40 41 |
# File 'lib/ascii_paradise/asciitable/row.rb', line 39 def table? @table end |