Class: TermUtils::Tab::Header
- Inherits:
-
Object
- Object
- TermUtils::Tab::Header
- Defined in:
- lib/term_utils/tab.rb
Overview
Represents a column header.
Instance Attribute Summary collapse
-
#align ⇒ Symbol
`:left`, `:right`.
- #title ⇒ String
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Header
constructor
Constructs a new Header.
-
#validate ⇒ nil
Validates the column represented by this one.
Constructor Details
#initialize(opts = {}) ⇒ Header
Constructs a new Header.
377 378 379 380 |
# File 'lib/term_utils/tab.rb', line 377 def initialize(opts = {}) @title = opts.fetch(:title) @align = opts.fetch(:align, :left) end |
Instance Attribute Details
#align ⇒ Symbol
Returns `:left`, `:right`.
371 372 373 |
# File 'lib/term_utils/tab.rb', line 371 def align @align end |
#title ⇒ String
369 370 371 |
# File 'lib/term_utils/tab.rb', line 369 def title @title end |
Instance Method Details
#validate ⇒ nil
Validates the column represented by this one.
385 386 387 388 |
# File 'lib/term_utils/tab.rb', line 385 def validate raise TermUtils::Tab::TableError, 'missing header title (nil)' if @title.nil? raise TermUtils::Tab::TableError, 'wrong header align (not :left or :right)' unless %i[left right].index(@align) end |