Class: TTY::Table::Operation::AlignmentSet
- Defined in:
- lib/tty/table/operation/alignment_set.rb
Overview
A class which responsiblity is to align table rows and header.
Instance Attribute Summary
Attributes included from Equatable
Instance Method Summary collapse
-
#[](index) ⇒ Symbol
Lookup an alignment by index.
-
#align_header(header, options = {}) ⇒ Array[String]
Align table header.
-
#align_rows(rows, options = {}) ⇒ Array[Array]
private
Align the supplied rows with the correct alignment.
-
#alignments ⇒ Array
private
Return each alignment in an Array.
Methods inherited from Vector
[], #[]=, #each, #empty?, #initialize, #size, #to_a, #to_ary
Methods included from Equatable
#attr_reader, included, #inherited
Methods included from Conversion
Constructor Details
This class inherits a constructor from TTY::Vector
Instance Method Details
#[](index) ⇒ Symbol
Lookup an alignment by index
17 18 19 |
# File 'lib/tty/table/operation/alignment_set.rb', line 17 def [](index) elements.fetch(index, :left) end |
#align_header(header, options = {}) ⇒ Array[String]
Align table header
35 36 37 |
# File 'lib/tty/table/operation/alignment_set.rb', line 35 def align_header(header, ={}) align_row(header, ) end |
#align_rows(rows, options = {}) ⇒ Array[Array]
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Align the supplied rows with the correct alignment.
47 48 49 |
# File 'lib/tty/table/operation/alignment_set.rb', line 47 def align_rows(rows, ={}) rows.map { |row| align_row(row, ) } end |
#alignments ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return each alignment in an Array
26 27 28 |
# File 'lib/tty/table/operation/alignment_set.rb', line 26 def alignments map { |alignment| alignment } end |