Class: Broach::Room
Overview
Represents a chat room on the server
Constant Summary collapse
- TYPE_MAP =
{ :text => 'TextMessage', :paste => 'PasteMessage', :sound => 'SoundMessage', :tweet => 'TweetMessage' }
Instance Method Summary collapse
-
#paste(content) ⇒ Object
Sends a paste to the room.
-
#sound(name) ⇒ Object
Sends a sound to the room.
-
#speak(content, options = {}) ⇒ Object
Send a message to the room.
Methods included from Attributes
#id, #initialize, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Broach::Attributes
Instance Method Details
#paste(content) ⇒ Object
Sends a paste to the room
This is basically a shortcut for speak(content, :type => :paste)
50 51 52 |
# File 'lib/broach/room.rb', line 50 def paste(content) speak(content, :type => :paste) end |
#sound(name) ⇒ Object
Sends a sound to the room
This is basically a shortcut for speak(name, :type => :sound)
43 44 45 |
# File 'lib/broach/room.rb', line 43 def sound(name) speak(name, :type => :sound) end |
#speak(content, options = {}) ⇒ Object
Send a message to the room
Parameters and options
content
-
Content to send. For a normal text message this is the content of the message. For a paste it’s the content of the paste. For a sound it’s the name of the sound.
:type
-
The type of message to send, this is :text by default for normal text messages. You can also use :paste and :sound. Valid sound messages are ‘rimshot’, ‘crickets’, or ‘trombone’.
Examples
room = Broach::Room.all.first
room.speak("Let's review these figures.")
room.speak("<code>$stderr.write('-')</code>", :type => :paste)
room.speak("rimshot", :type => :sound)
32 33 34 35 36 37 38 |
# File 'lib/broach/room.rb', line 32 def speak(content, ={}) [:type] ||= :text Broach.session.post("room/#{id}/speak", 'message' => { 'type' => TYPE_MAP[[:type]], 'body' => friendly_coerce_to_string(content) })['message'] end |