Class: VisualWidth::Formatter::Align
- Inherits:
-
Object
- Object
- VisualWidth::Formatter::Align
- Defined in:
- lib/visual_width/formatter.rb
Instance Method Summary collapse
Instance Method Details
#center(cell, width) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/visual_width/formatter.rb', line 17 def center(cell, width) align(cell, width) do |line, fill| half = fill / 2.0 (' ' * half.floor) + line + (' ' * half.ceil) end end |
#left(cell, width) ⇒ Object
5 6 7 8 9 |
# File 'lib/visual_width/formatter.rb', line 5 def left(cell, width) align(cell, width) do |line, fill| line + (' ' * fill) end end |
#right(cell, width) ⇒ Object
11 12 13 14 15 |
# File 'lib/visual_width/formatter.rb', line 11 def right(cell, width) align(cell, width) do |line, fill| (' ' * fill) + line end end |