Method: String#left_just
- Defined in:
- lib/tefil/columnformer.rb
#left_just(width, padding = ' ') ⇒ Object
www.techscore.com/blog/2012/12/25/ def mb_ljust(width, padding=‘ ’)
9 10 11 12 13 |
# File 'lib/tefil/columnformer.rb', line 9 def left_just(width, padding=' ') output_width = each_char.map{|c| c.bytesize == 1 ? 1 : 2}.reduce(0, &:+) padding_size = [0, width - output_width].max self + padding * padding_size end |