lib/socrates/adapters/console_adapter.rb in socrates-0.1.1 vs lib/socrates/adapters/console_adapter.rb in socrates-0.1.2

- old
+ new

@@ -1,34 +1,53 @@ -class ConsoleAdapter - CLIENT_ID = "CONSOLE" +module Socrates + module Adapters + class ConsoleAdapter + CLIENT_ID = "CONSOLE" - def initialize(name: "@socrates") - @name = name - end + attr_accessor :email, :users - def client_id_from_context(_context) - CLIENT_ID - end + def initialize(name: "@socrates") + @name = name + @users = [] + end - def send_message(message, *) - puts "\n#{colorize(@name, "32;1")}: #{message}" - end + def client_id_from_context(_context) + CLIENT_ID + end - def send_direct_message(message, user, *) - name = - if user.respond_to?(:name) - user.name - elsif user.respond_to?(:id) - user.id - else - user + def send_message(message, *) + puts "\n#{colorize(@name, "32;1")}: #{message}" end - puts "\n[DM] #{colorize(name, "34;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 - private + puts "\n[DM] #{colorize(name, "34;1")}: #{message}" + end - def colorize(str, color_code) - "\e[#{color_code}m#{str}\e[0m" + 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