Class: Jabbot::Message
- Inherits:
-
Struct
- Object
- Struct
- Jabbot::Message
- Defined in:
- lib/jabbot/bot.rb
Overview
A message consists of the username, the text, a time when it was received and the type of the message.
The type could be one Symbol of:
* :public
* :private
* :join
* :leave
* :subject
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
-
#time ⇒ Object
Returns the value of attribute time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#to_json(*a) ⇒ Object
Public: Encode a message in JSON.
-
#to_s ⇒ Object
Public: Converts the message to printable text.
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text
19 20 21 |
# File 'lib/jabbot/bot.rb', line 19 def text @text end |
#time ⇒ Object
Returns the value of attribute time
19 20 21 |
# File 'lib/jabbot/bot.rb', line 19 def time @time end |
#type ⇒ Object
Returns the value of attribute type
19 20 21 |
# File 'lib/jabbot/bot.rb', line 19 def type @type end |
#user ⇒ Object
Returns the value of attribute user
19 20 21 |
# File 'lib/jabbot/bot.rb', line 19 def user @user end |
Instance Method Details
#to_json(*a) ⇒ Object
Public: Encode a message in JSON
Returns the json-ified String of the Hash representation of this message.
30 31 32 33 34 35 36 37 |
# File 'lib/jabbot/bot.rb', line 30 def to_json(*a) { :user => user, :text => text, :time => time, :type => type }.to_json(*a) end |
#to_s ⇒ Object
Public: Converts the message to printable text.
Returns a String containing the user’s name and the text.
23 24 25 |
# File 'lib/jabbot/bot.rb', line 23 def to_s "#{user}: #{text}" end |