Class: TermUtils::Tab::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/term_utils/tab.rb

Overview

Represents a column header.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Header

Constructs a new Header.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :title (String)
  • :align (Symbol)


376
377
378
379
# File 'lib/term_utils/tab.rb', line 376

def initialize(opts = {})
  @title = opts.fetch(:title)
  @align = opts.fetch(:align, :left)
end

Instance Attribute Details

#alignSymbol

Returns ‘:left`, `:right`.

Returns:

  • (Symbol)

    ‘:left`, `:right`.



370
371
372
# File 'lib/term_utils/tab.rb', line 370

def align
  @align
end

#titleString

Returns:

  • (String)


368
369
370
# File 'lib/term_utils/tab.rb', line 368

def title
  @title
end

Instance Method Details

#validatenil

Validates the column represented by this one.

Returns:

  • (nil)

Raises:



384
385
386
387
# File 'lib/term_utils/tab.rb', line 384

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