Sha256: 8f83030323d9de30dc6d89d52861ef496a50be207ac074b6b74bceb6e2ad0108

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module SpicedRumby
  class CLIOutput < MeshChat::Display::Base
    def start
      puts "\n"
      alert 'Welcome to Spiced Rumby!'
      puts "\n"
      puts "\n"
      yield if block_given?

      MeshChat::CLI.listen_for_commands
    end

    # TODO: find a more elegant way to handle color
    def add_line(line)
      puts line
    end

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

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

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

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

    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

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spiced_rumby-0.7.0 lib/spiced_rumby/cli_output.rb
spiced_rumby-0.6.0 lib/spiced_rumby/cli_output.rb