Class: Protolink::Channel
- Inherits:
-
Object
- Object
- Protolink::Channel
- Defined in:
- lib/protolink/channel.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#global ⇒ Object
readonly
Returns the value of attribute global.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Instance Method Summary collapse
- #delete! ⇒ Object
-
#initialize(connection, attributes = {}) ⇒ Channel
constructor
A new instance of Channel.
- #listen ⇒ Object
- #listener ⇒ Object
-
#speak(message, options = {}) ⇒ Object
Post a new message to the chat channel.
Constructor Details
#initialize(connection, attributes = {}) ⇒ Channel
Returns a new instance of Channel.
5 6 7 8 9 10 11 12 13 |
# File 'lib/protolink/channel.rb', line 5 def initialize(connection, attributes = {}) @connection = connection @id = attributes['id'] @name = attributes['name'] @description = attributes['description'] @global = attributes['global'] @uuid = attributes['uuid'] @loaded = false end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/protolink/channel.rb', line 3 def description @description end |
#global ⇒ Object (readonly)
Returns the value of attribute global.
3 4 5 |
# File 'lib/protolink/channel.rb', line 3 def global @global end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/protolink/channel.rb', line 3 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/protolink/channel.rb', line 3 def name @name end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
3 4 5 |
# File 'lib/protolink/channel.rb', line 3 def uuid @uuid end |
Instance Method Details
#delete! ⇒ Object
21 22 23 |
# File 'lib/protolink/channel.rb', line 21 def delete! connection.delete("/api/v1/channels/#{self.id}") end |
#listen ⇒ Object
32 33 34 |
# File 'lib/protolink/channel.rb', line 32 def listen end |
#listener ⇒ Object
25 26 27 28 29 30 |
# File 'lib/protolink/channel.rb', line 25 def listener users = connection.get("/api/v1/channels/#{self.id}/users") users && users.map do |user| User.new(connection, user) end end |
#speak(message, options = {}) ⇒ Object
Post a new message to the chat channel
17 18 19 |
# File 'lib/protolink/channel.rb', line 17 def speak(, = {}) (, ) end |