Class: SelfSDK::Chat::Group
- Inherits:
-
Object
- Object
- SelfSDK::Chat::Group
- Defined in:
- lib/chat/group.rb
Instance Attribute Summary collapse
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#members ⇒ Object
Returns the value of attribute members.
-
#name ⇒ Object
Returns the value of attribute name.
-
#payload ⇒ Object
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(chat, payload) ⇒ Group
constructor
A new instance of Group.
-
#invite(user) ⇒ Object
Sends an invitation to the specified user to join the group.
-
#join ⇒ Object
Sends a confi¡rmation message that has joined the group.
-
#leave ⇒ Object
Sends a message to leave the current group.
-
#message(body, opts = {}) ⇒ Object
Sends a message to the current group.
Constructor Details
#initialize(chat, payload) ⇒ Group
Returns a new instance of Group.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/chat/group.rb', line 10 def initialize(chat, payload) @chat = chat @payload = payload @gid = payload[:gid] @members = payload[:members] @name = payload[:name] @link = payload[:link] if payload.key? :link @key = payload[:key] if payload.key? :key @mime = payload[:mime] if payload.key? :mime end |
Instance Attribute Details
#gid ⇒ Object
Returns the value of attribute gid.
8 9 10 |
# File 'lib/chat/group.rb', line 8 def gid @gid end |
#members ⇒ Object
Returns the value of attribute members.
8 9 10 |
# File 'lib/chat/group.rb', line 8 def members @members end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/chat/group.rb', line 8 def name @name end |
#payload ⇒ Object
Returns the value of attribute payload.
8 9 10 |
# File 'lib/chat/group.rb', line 8 def payload @payload end |
Instance Method Details
#invite(user) ⇒ Object
Sends an invitation to the specified user to join the group.
25 26 27 28 29 30 |
# File 'lib/chat/group.rb', line 25 def invite(user) raise "invalid input" if user.empty? @members << user @chat.invite(@gid, @name, @members) end |
#join ⇒ Object
Sends a confi¡rmation message that has joined the group.
38 39 40 |
# File 'lib/chat/group.rb', line 38 def join @chat.join(@gid, @members) end |
#leave ⇒ Object
Sends a message to leave the current group.
33 34 35 |
# File 'lib/chat/group.rb', line 33 def leave @chat.leave(@gid, @members) end |
#message(body, opts = {}) ⇒ Object
Sends a message to the current group
45 46 47 48 |
# File 'lib/chat/group.rb', line 45 def (body, opts = {}) opts[:gid] = @gid @chat.(@members, body, opts) end |