Class: Protolink::Channel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/protolink/channel.rb', line 3

def description
  @description
end

#globalObject (readonly)

Returns the value of attribute global.



3
4
5
# File 'lib/protolink/channel.rb', line 3

def global
  @global
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/protolink/channel.rb', line 3

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/protolink/channel.rb', line 3

def name
  @name
end

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

#listenObject



32
33
34
# File 'lib/protolink/channel.rb', line 32

def listen
  
end

#listenerObject



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(message, options = {})
  send_message(message, options)
end