Method: App::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.

Returns:

  • void



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/core/terminal.rb', line 69

def self.output(message = 'No message', type = MSG_INFO, title = nil, bg_color = nil)
    case type
        when MSG_INFO
            puts "\x1B[48;5;2m Executing \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_WARNING
            puts "\x1B[48;5;202m  Warning  \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_ERROR
            puts "\x1B[48;5;196m   Error   \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_TODO
            puts "\x1B[48;5;199m   @TODO   \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_AUTOMATIC
            puts "\x1B[48;5;96m Automatic \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_GENERATED
            puts "\x1B[48;5;96m Generated \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_PROCESSED
            puts "\x1B[48;5;238m Processed \x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        when MSG_CUSTOM
            raise RuntimeError, "'title' cannot be nil." if title.nil?
            raise RuntimeError, "'bg_color' cannot be nil." if bg_color.nil?
            puts "\x1B[48;5;#{bg_color}m#{title}\x1B[0m \x1B[0m\xe2\x86\x92\x1B[0m \x1B[0m#{message}\x1B[0m"
        else
            puts "'#{type}' is not a valid Terminal::output() type."
            exit
    end
end