Sha256: 1ff829a7faf82bce61680707a84d10316e7cb3e14e8807dbe8288d2042ceae48
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require "socrates/adapters/stubs" module Socrates module Adapters class Console 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
socrates-0.1.10 | lib/socrates/adapters/console.rb |
socrates-0.1.9 | lib/socrates/adapters/console.rb |
socrates-0.1.8 | lib/socrates/adapters/console.rb |