Module: Printable
- Included in:
- Ballantine::Author, Ballantine::CLI
- Defined in:
- lib/printable.rb
Instance Method Summary collapse
Instance Method Details
#cols ⇒ Integer
21 22 23 24 25 26 27 |
# File 'lib/printable.rb', line 21 def cols return @_cols if defined?(@_cols) require "io/console" _lines, @_cols = IO.console.winsize @_cols end |
#puts_r(msg, msg_r) ⇒ NilClass
7 8 9 10 |
# File 'lib/printable.rb', line 7 def puts_r(msg, msg_r) size = rjust_size(msg, msg_r) puts msg + msg_r.rjust(size) end |
#rjust_size(msg, msg_r) ⇒ Integer
15 16 17 18 |
# File 'lib/printable.rb', line 15 def rjust_size(msg, msg_r) sanitized = ->(str) { str.sanitize_colored.size + str.scan(/\p{Hangul}/).size } cols - sanitized.call(msg) - sanitized.call(msg_r) + msg_r.size end |