Module: Termline::Msg

Defined in:
lib/termline/msg.rb

Class Method Summary collapse

Class Method Details

.alert(message) ⇒ Object



57
58
59
60
# File 'lib/termline/msg.rb', line 57

def alert message
    puts("\e[5m#{message}\e[0m")
    puts("\e[5m#{Style.colorize(message,:red)}\e[0m")
end

.builder(message, tag: nil, icon: nil, color: :default, bgcolor: :default, timestamp: Time.now.strftime('%H:%M:%S:%L'), time: true, data: nil) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/termline/msg.rb', line 37

def builder(
    message, 
    tag: nil,
    icon: nil,
    color: :default, 
    bgcolor: :default, 
    timestamp: Time.now.strftime('%H:%M:%S:%L'), 
    time:true,
    data:nil)

    parts = []
    parts << "[#{timestamp}]" if time
    parts << Style.colorize(Style.icon(icon), color) if icon
    parts << Style.colorize(tag, color) if tag
    parts << message
    parts << data_text(data, color) if data

    parts.compact.map(&:to_s).reject(&:empty?).join(" ").strip
end