Sha256: fc35100319e56e0b92b5f4c24b4a08e515f38c05a9cdab6ddce9098aa20bd272

Contents?: true

Size: 1012 Bytes

Versions: 2

Compression:

Stored size: 1012 Bytes

Contents

module Gamefic
  module Active
    # A module for active entities that provides a default Messenger with
    # a few shortcuts.
    #
    module Messaging
      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

2 entries across 2 versions & 1 rubygems

Version Path
gamefic-3.1.0 lib/gamefic/active/messaging.rb
gamefic-3.0.0 lib/gamefic/active/messaging.rb