Class: Del::Source
- Inherits:
-
Object
- Object
- Del::Source
- Defined in:
- lib/del/source.rb
Overview
This represents the source of a chat message.
Instance Attribute Summary collapse
-
#room ⇒ Object
readonly
Returns the value of attribute room.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #from?(robot) ⇒ Boolean
-
#initialize(user:, room: nil) ⇒ Source
constructor
A new instance of Source.
- #reply(robot, message) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(user:, room: nil) ⇒ Source
Returns a new instance of Source.
8 9 10 11 |
# File 'lib/del/source.rb', line 8 def initialize(user:, room: nil) @user = user @room = room end |
Instance Attribute Details
#room ⇒ Object (readonly)
Returns the value of attribute room.
6 7 8 |
# File 'lib/del/source.rb', line 6 def room @room end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
6 7 8 |
# File 'lib/del/source.rb', line 6 def user @user end |
Instance Method Details
#from?(robot) ⇒ Boolean
13 14 15 |
# File 'lib/del/source.rb', line 13 def from?(robot) user.jid == robot.jid.to_s end |
#reply(robot, message) ⇒ Object
17 18 19 |
# File 'lib/del/source.rb', line 17 def reply(robot, ) robot.(room || user.jid, ) end |
#to_s ⇒ Object
21 22 23 |
# File 'lib/del/source.rb', line 21 def to_s "#{user.mention_name}#{room ? ":#{room}" : nil}" end |