Method: Blufin::Terminal.output
- Defined in:
- lib/core/terminal.rb
.output(message = 'No message', type = MSG_INFO, title = nil, bg_color = nil) ⇒ Object
Outputs messages to the terminal. If CUSTOM, title must be 11 characters to match existing scheme.
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/core/terminal.rb', line 136 def self.output( = 'No message', type = MSG_INFO, title = nil, bg_color = nil) raise RuntimeError, "'title' cannot be nil." if title.nil? && [MSG_CUSTOM, MSG_CUSTOM_AUTO_PAD].include?(type) raise RuntimeError, "'bg_color' cannot be nil." if bg_color.nil? && [MSG_CUSTOM, MSG_CUSTOM_AUTO_PAD].include?(type) raise RuntimeError, "'title' cannot be more that 9 characerts when MSG_CUSTOM_AUTO_PAD is the message type." if type == MSG_CUSTOM_AUTO_PAD && title.length > 9 case type when MSG_INFO puts "\x1B[38;5;231m\x1B[48;5;22m Executing \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_WARNING puts "\x1B[38;5;231m\x1B[48;5;202m Warning \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_ERROR puts "\x1B[38;5;231m\x1B[48;5;196m Error \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_TODO puts "\x1B[38;5;231m\x1B[48;5;199m @TODO \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_AUTOMATIC puts "\x1B[38;5;231m\x1B[48;5;96m Automatic \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_GENERATED puts "\x1B[38;5;231m\x1B[48;5;96m Generated \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_PROCESSED puts "\x1B[38;5;231m\x1B[48;5;238m Processed \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_PROGRESS puts " \x1B[38;5;240m#{}\x1B[0m\n" when MSG_CUSTOM puts "\x1B[38;5;231m\x1B[48;5;#{bg_color}m#{title}\x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" when MSG_CUSTOM_AUTO_PAD puts "\x1B[38;5;231m#{''.rjust((9 - title.length), ' ')}\x1B[48;5;#{bg_color}m #{title} \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{}\x1B[0m\n" else raise RuntimeError, "Invalid Terminal::output type: #{type}" end end |