Class: Fabriq::Adapter::RypeAdapter
- Inherits:
-
Object
- Object
- Fabriq::Adapter::RypeAdapter
- Defined in:
- lib/fabriq/adapter/rype_adapter.rb
Instance Method Summary collapse
- #attach(&block) ⇒ Object
- #available_rooms(&block) ⇒ Object
- #load_room_information(room, &block) ⇒ Object
- #message_received(&block) ⇒ Object
- #send_message(chat, body) ⇒ Object
- #wait ⇒ Object
Instance Method Details
#attach(&block) ⇒ Object
8 9 10 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 8 def attach(&block) ::Rype.attach end |
#available_rooms(&block) ⇒ Object
32 33 34 35 36 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 32 def available_rooms(&block) Rype::Chat.all do |chats| yield chats end end |
#load_room_information(room, &block) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 38 def load_room_information(room, &block) room.topic do |topic| room.members do |members| yield({ topic: topic, id: room.chatname, members: members, raw: room }) end end end |
#message_received(&block) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 16 def (&block) Rype.on(:chatmessage_received) do || .chat do |chat| .body do |body| .from_name do |from_name| Thread.new { yield({ from_name: from_name, body: body, room_id: chat.chatname }) } end end end end end |
#send_message(chat, body) ⇒ Object
28 29 30 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 28 def (chat, body) chat.(body) end |
#wait ⇒ Object
12 13 14 |
# File 'lib/fabriq/adapter/rype_adapter.rb', line 12 def wait ::Rype.thread.join end |