Class: Del::Source

Inherits:
Object
  • Object
show all
Defined in:
lib/del/source.rb

Overview

This represents the source of a chat message.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#roomObject (readonly)

Returns the value of attribute room.



6
7
8
# File 'lib/del/source.rb', line 6

def room
  @room
end

#userObject (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

Returns:

  • (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, message)
  robot.send_message(room || user.jid, message)
end

#to_sObject



21
22
23
# File 'lib/del/source.rb', line 21

def to_s
  "#{user.mention_name}#{room ? ":#{room}" : nil}"
end