Class: DevSuite::Utils::Table::Formatter::TextAligner

Inherits:
Object
  • Object
show all
Defined in:
lib/dev_suite/utils/table/formatter/text_aligner.rb

Class Method Summary collapse

Class Method Details

.align(text, width, alignment = :left) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dev_suite/utils/table/formatter/text_aligner.rb', line 9

def align(text, width, alignment = :left)
  case alignment
  when :left
    text.ljust(width)
  when :right
    text.rjust(width)
  when :center
    text.center(width)
  else
    text
  end
end