Class: Tabulo::Column
- Inherits:
-
Object
- Object
- Tabulo::Column
- Defined in:
- lib/tabulo/column.rb
Instance Attribute Summary collapse
-
#label ⇒ Object
readonly
Returns the value of attribute label.
-
#truncate ⇒ Object
readonly
Returns the value of attribute truncate.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #body_cell(source) ⇒ Object
- #body_cell_value(source) ⇒ Object
- #header_cell ⇒ Object
- #horizontal_rule ⇒ Object
-
#initialize(options) ⇒ Column
constructor
A new instance of Column.
Constructor Details
#initialize(options) ⇒ Column
Returns a new instance of Column.
7 8 9 10 11 12 13 14 |
# File 'lib/tabulo/column.rb', line 7 def initialize() @label, @header = [:label], [:header] @truncate = [:truncate] @align_header, @align_body = [:align_header], [:align_body] @extractor, @formatter = [:extractor], [:formatter] @width = [:width] @horizontal_rule_character = [:horizontal_rule_character] end |
Instance Attribute Details
#label ⇒ Object (readonly)
Returns the value of attribute label.
5 6 7 |
# File 'lib/tabulo/column.rb', line 5 def label @label end |
#truncate ⇒ Object (readonly)
Returns the value of attribute truncate.
5 6 7 |
# File 'lib/tabulo/column.rb', line 5 def truncate @truncate end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
5 6 7 |
# File 'lib/tabulo/column.rb', line 5 def width @width end |
Instance Method Details
#body_cell(source) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/tabulo/column.rb', line 24 def body_cell(source) cell_datum = body_cell_value(source) formatted_cell_content = @formatter.call(cell_datum) real_alignment = @align_body || infer_alignment(cell_datum) align_cell_content(formatted_cell_content, real_alignment) end |
#body_cell_value(source) ⇒ Object
31 32 33 |
# File 'lib/tabulo/column.rb', line 31 def body_cell_value(source) @extractor.call(source) end |
#header_cell ⇒ Object
16 17 18 |
# File 'lib/tabulo/column.rb', line 16 def header_cell align_cell_content(@header, @align_header) end |
#horizontal_rule ⇒ Object
20 21 22 |
# File 'lib/tabulo/column.rb', line 20 def horizontal_rule @horizontal_rule_character * @width end |