Class: EtherpadLite::ChatMessage
- Inherits:
-
Object
- Object
- EtherpadLite::ChatMessage
- Defined in:
- lib/etherpad-lite/models/chat_message.rb
Overview
An Etherpad Lite Chat message
Instance Attribute Summary collapse
-
#instance ⇒ Object
readonly
The EtherpadLite::Instance object.
-
#pad_id ⇒ Object
readonly
The pad id.
-
#text ⇒ Object
readonly
The message text.
-
#timestamp ⇒ Object
readonly
Unix timestamp.
-
#user_id ⇒ Object
readonly
User/Author id.
-
#user_name ⇒ Object
readonly
User/Author name.
Instance Method Summary collapse
-
#author ⇒ Object
(also: #user)
Returns the Author that sent this message.
-
#initialize(instance, attrs) ⇒ ChatMessage
constructor
Instantiate a ChatMessage.
-
#pad ⇒ Object
Returns this message’s Pad.
-
#time ⇒ Object
Time object.
-
#to_s ⇒ Object
Returns the message text.
Constructor Details
#initialize(instance, attrs) ⇒ ChatMessage
Instantiate a ChatMessage
18 19 20 21 22 23 24 25 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 18 def initialize(instance, attrs) @instance = instance @pad_id = attrs[:padID] @text = attrs[:text] @user_id = attrs[:userId] @timestamp = attrs[:time] / 1000 if attrs[:time] @user_name = attrs[:userName] end |
Instance Attribute Details
#instance ⇒ Object (readonly)
The EtherpadLite::Instance object
5 6 7 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 5 def instance @instance end |
#pad_id ⇒ Object (readonly)
The pad id
7 8 9 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 7 def pad_id @pad_id end |
#text ⇒ Object (readonly)
The message text
9 10 11 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 9 def text @text end |
#timestamp ⇒ Object (readonly)
Unix timestamp
13 14 15 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 13 def @timestamp end |
#user_id ⇒ Object (readonly)
User/Author id
11 12 13 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 11 def user_id @user_id end |
#user_name ⇒ Object (readonly)
User/Author name
15 16 17 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 15 def user_name @user_name end |
Instance Method Details
#author ⇒ Object Also known as: user
Returns the Author that sent this message
37 38 39 40 41 42 43 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 37 def if user_id @author ||= Author.new(instance, user_id) else nil end end |
#pad ⇒ Object
Returns this message’s Pad
28 29 30 31 32 33 34 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 28 def pad if pad_id @pad ||= Pad.new(instance, pad_id) else nil end end |
#time ⇒ Object
Time object
48 49 50 51 52 53 54 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 48 def time if @time ||= Time.at() else nil end end |
#to_s ⇒ Object
Returns the message text
57 58 59 |
# File 'lib/etherpad-lite/models/chat_message.rb', line 57 def to_s text.to_s end |