Method: String#align

Defined in:
lib/core/facets/string/align.rb

#align(direction, n, sep = "\n", c = ' ') ⇒ Object

Alignment method dispatches to #align_right, #align_left or #align_center, accorging to the first direction parameter.

s = <<-EOS
This is a test
  and
  so on
EOS

s.align(:right, 14)

produces

This is a test
           and
         so on

Returns a String aligned right, left or center.



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/core/facets/string/align.rb', line 21

def align(direction, n, sep="\n", c=' ')
  case direction
  when :right
    align_right(n, sep="\n", c=' ')
  when :left
    align_left(n, sep="\n", c=' ')
  when :center
    align_center(n, sep="\n", c=' ')
  else
    raise ArgumentError
  end
end