Sha256: 5f1191745dc90042379f5c1bf6f5e06a67dcfa29cd1f153a239d227d71585fdf
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Socrates module Adapters class ConsoleAdapter CLIENT_ID = "CONSOLE" attr_accessor :email, :users def initialize(name: "@socrates") @name = name @users = [] end def client_id_from_context(_context) CLIENT_ID end def send_message(message, *) puts "\n#{colorize(@name, "32;1")}: #{message}" end def send_direct_message(message, user, *) name = if user.respond_to?(:name) user.name elsif user.respond_to?(:id) user.id else user end puts "\n[DM] #{colorize(name, "34;1")}: #{message}" end def add_user(id: nil, name: nil, first: nil, last: nil, email: nil) users << User.new(id, name, Profile.new(first, last, email)) end def users_list Response.new(users) end def lookup_email(*) email end private def colorize(str, color_code) "\e[#{color_code}m#{str}\e[0m" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems