Sha256: b375acc8e8bc7e80d2578930d6f16e06a678c892ff20a4fd9c1b2b3a0ef6e9af

Contents?: true

Size: 551 Bytes

Versions: 1

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

module Whatup
  module Server
    class Room
      attr_accessor *%i[name clients]

      def initialize name:, clients:
        @name = name
        @clients = clients

        @clients.each { |c| c.room = self }
      end

      def drop_client! client
        @clients = @clients.reject { |c| c == client }
      end

      def broadcast except: nil
        clients = except \
          ? @clients.reject { |c| c == except }
          : @clients

        clients.each { |c| c.puts yield }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whatup-0.2.4 lib/whatup/server/room.rb