Sha256: e312e07a768d314a8c3cfa39dacb2997cc088b8042bf99a647ba70fce7abf2be

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Gamefic
  module Active
    # A module for active entities that provides a default Messenger with
    # a few shortcuts.
    #
    module Messaging
      # @return [Messenger]
      def messenger
        @messenger ||= Messenger.new
      end

      # Send a message to the entity.
      #
      # This method will automatically wrap the message in HTML paragraphs.
      # To send a message without paragraph formatting, use #stream instead.
      #
      # @param message [String]
      def tell(message)
        messenger.tell message
      end

      # Send a message to the entity as raw text.
      #
      # Unlike #tell, this method will not wrap the message in HTML paragraphs.
      #
      # @param message [String]
      def stream(message)
        messenger.stream message
      end

      def messages
        messenger.messages
      end

      def buffer &block
        messenger.buffer(&block)
      end

      def flush
        messenger.flush
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gamefic-3.6.0 lib/gamefic/active/messaging.rb
gamefic-3.5.0 lib/gamefic/active/messaging.rb
gamefic-3.4.0 lib/gamefic/active/messaging.rb
gamefic-3.3.0 lib/gamefic/active/messaging.rb