Module: Gamefic::Active::Messaging
- Included in:
- Gamefic::Active
- Defined in:
- lib/gamefic/active/messaging.rb
Overview
A module for active entities that provides a default Messenger with a few shortcuts.
Instance Method Summary collapse
-
#buffer(&block) ⇒ String
Create a temporary buffer while yielding the given block and return the buffered text.
-
#flush ⇒ String
Clear the current buffer.
- #messages ⇒ String
- #messenger ⇒ Messenger
-
#stream(message) ⇒ Object
Send a message to the entity as raw text.
-
#tell(message) ⇒ Object
Send a message to the entity.
Instance Method Details
#buffer(&block) ⇒ String
Create a temporary buffer while yielding the given block and return the buffered text.
42 43 44 |
# File 'lib/gamefic/active/messaging.rb', line 42 def buffer &block messenger.buffer(&block) end |
#flush ⇒ String
Clear the current buffer.
49 50 51 |
# File 'lib/gamefic/active/messaging.rb', line 49 def flush messenger.flush end |
#messenger ⇒ Messenger
10 11 12 |
# File 'lib/gamefic/active/messaging.rb', line 10 def messenger @messenger ||= Messenger.new end |
#stream(message) ⇒ Object
Send a message to the entity as raw text.
Unlike #tell, this method will not wrap the message in HTML paragraphs.
29 30 31 |
# File 'lib/gamefic/active/messaging.rb', line 29 def stream() messenger.stream end |
#tell(message) ⇒ Object
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.
20 21 22 |
# File 'lib/gamefic/active/messaging.rb', line 20 def tell() messenger.tell end |