Class: Sangi::TerminalWidthWarning
- Inherits:
-
Object
- Object
- Sangi::TerminalWidthWarning
- Defined in:
- lib/sangi/terminal_width_warning.rb
Instance Method Summary collapse
-
#initialize(output:) ⇒ TerminalWidthWarning
constructor
A new instance of TerminalWidthWarning.
- #message(steps) ⇒ Object
- #warn_once(steps, error_output:) ⇒ Object
Constructor Details
#initialize(output:) ⇒ TerminalWidthWarning
Returns a new instance of TerminalWidthWarning.
5 6 7 |
# File 'lib/sangi/terminal_width_warning.rb', line 5 def initialize(output:) @output = output end |
Instance Method Details
#message(steps) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/sangi/terminal_width_warning.rb', line 9 def (steps) width = terminal_width return nil if width.nil? || steps.empty? required = required_width(steps) return nil if required <= width "warning: terminal width is #{width}, but this board needs about #{required} columns; output may wrap." end |
#warn_once(steps, error_output:) ⇒ Object
19 20 21 22 |
# File 'lib/sangi/terminal_width_warning.rb', line 19 def warn_once(steps, error_output:) warning = (steps) error_output.puts warning if warning end |