Class: ChatSDK::Channel

Inherits:
Object
  • Object
show all
Defined in:
lib/chat_sdk/channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, adapter:, chat:) ⇒ Channel

Returns a new instance of Channel.



7
8
9
10
11
# File 'lib/chat_sdk/channel.rb', line 7

def initialize(id:, adapter:, chat:)
  @id = id
  @adapter = adapter
  @chat = chat
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



5
6
7
# File 'lib/chat_sdk/channel.rb', line 5

def adapter
  @adapter
end

#chatObject (readonly)

Returns the value of attribute chat.



5
6
7
# File 'lib/chat_sdk/channel.rb', line 5

def chat
  @chat
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/chat_sdk/channel.rb', line 5

def id
  @id
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



22
23
24
# File 'lib/chat_sdk/channel.rb', line 22

def ==(other)
  other.is_a?(Channel) && id == other.id
end

#hashObject



27
28
29
# File 'lib/chat_sdk/channel.rb', line 27

def hash
  id.hash
end

#post(content) ⇒ Object



13
14
15
16
# File 'lib/chat_sdk/channel.rb', line 13

def post(content)
  message = PostableMessage.from(content)
  adapter.post_message(channel_id: id, message: message)
end

#thread(thread_id) ⇒ Object



18
19
20
# File 'lib/chat_sdk/channel.rb', line 18

def thread(thread_id)
  ChatSDK::Thread.new(id: thread_id, channel_id: id, adapter: adapter, chat: chat)
end