Module: LoggerEnhancement
- Defined in:
- lib/easy_io/logger.rb
Overview
Add a couple methods to the Logger class
Instance Method Summary collapse
- #header(header_text = '', header_type: :standard, filler_character: '*') ⇒ Object
- #line(filler_character) ⇒ Object
Instance Method Details
#header(header_text = '', header_type: :standard, filler_character: '*') ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/easy_io/logger.rb', line 10 def header(header_text = '', header_type: :standard, filler_character: '*') terminal_columns = EasyIO::Terminal.columns max_header_size = terminal_columns - 31 # Allow at least 1 character on either side of the header header_text = header_text[0...max_header_size] if header_text.length > max_header_size # Truncate the header if it is too big filler = filler_character * ((terminal_columns - (header_text.length + 29)) / 2) info filler_character * (terminal_columns - 27) if [:primary, :secondary].include?(header_type) info "#{filler} #{header_text} #{filler}" + filler_character * ((terminal_columns + header_text.length + 1) % 2) info filler_character * (terminal_columns - 27) if header_type == :primary end |