Class: SpicedRumby::CLIOutput

Inherits:
MeshChat::Display::Base
  • Object
show all
Defined in:
lib/spiced_rumby/cli_output.rb

Instance Method Summary collapse

Instance Method Details

#add_line(line) ⇒ Object

TODO: find a more elegant way to handle color



14
15
16
# File 'lib/spiced_rumby/cli_output.rb', line 14

def add_line(line)
  puts line
end

#alert(msg) ⇒ Object



26
27
28
# File 'lib/spiced_rumby/cli_output.rb', line 26

def alert(msg)
  puts msg.colorize(:red)
end

#chat(msg) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/spiced_rumby/cli_output.rb', line 34

def chat(msg)
  words = msg.split(' ')
  time = words[0..1]
  name = words[2]
  message = words[3..words.length]

  print (time.join(' ') + ' ').colorize(:light_magenta)
  print (name + ' ').colorize(:cyan)
  print message.join(' ') + "\n"
end

#info(msg) ⇒ Object



18
19
20
# File 'lib/spiced_rumby/cli_output.rb', line 18

def info(msg)
  puts msg.colorize(:light_black)
end

#startObject



3
4
5
6
7
8
9
10
11
# File 'lib/spiced_rumby/cli_output.rb', line 3

def start
  puts "\n"
  alert 'Welcome to Spiced Rumby!'
  puts "\n"
  puts "\n"
  yield if block_given?

  MeshChat::CLI.listen_for_commands
end

#success(msg) ⇒ Object



30
31
32
# File 'lib/spiced_rumby/cli_output.rb', line 30

def success(msg)
  puts msg.colorize(:green)
end

#warning(msg) ⇒ Object



22
23
24
# File 'lib/spiced_rumby/cli_output.rb', line 22

def warning(msg)
  puts msg.colorize(:yellow)
end

#whisper(msg) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/spiced_rumby/cli_output.rb', line 45

def whisper(msg)
  words = msg.split(' ')
  time = words[0..1]
  name = words[2]
  message = words[3..words.length]

  print (time.join(' ') + ' ').colorize(:magenta)
  print (name + ' ').colorize(:light_black)
  print message.join(' ') + "\n"
end