Class: Lita::Adapters::Slack::SlackChannel

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/adapters/slack/slack_channel.rb

Overview

A struct representing a Slack channel, group, or IM.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, created, creator, raw_data) ⇒ SlackChannel

Returns a new instance of SlackChannel.


36
37
38
39
40
41
42
# File 'lib/lita/adapters/slack/slack_channel.rb', line 36

def initialize(id, name, created, creator, raw_data)
  @id       = id
  @name     = name
  @created  = created
  @creator  = creator
  @raw_data = raw_data
end

Instance Attribute Details

#createdString (readonly)

Returns A timestamp indicating when the channel was created.

Returns:

  • (String)

    A timestamp indicating when the channel was created.


30
31
32
# File 'lib/lita/adapters/slack/slack_channel.rb', line 30

def created
  @created
end

#creatorString (readonly)

Returns The unique ID of the user who created the channel.

Returns:

  • (String)

    The unique ID of the user who created the channel.


32
33
34
# File 'lib/lita/adapters/slack/slack_channel.rb', line 32

def creator
  @creator
end

#idString (readonly)

Returns The channel's unique ID.

Returns:

  • (String)

    The channel's unique ID.


26
27
28
# File 'lib/lita/adapters/slack/slack_channel.rb', line 26

def id
  @id
end

#nameString (readonly)

Returns The human-readable name for the channel.

Returns:

  • (String)

    The human-readable name for the channel.


28
29
30
# File 'lib/lita/adapters/slack/slack_channel.rb', line 28

def name
  @name
end

#raw_dataHash (readonly)

Returns The raw channel data received from Slack, including many more fields.

Returns:

  • (Hash)

    The raw channel data received from Slack, including many more fields.


34
35
36
# File 'lib/lita/adapters/slack/slack_channel.rb', line 34

def raw_data
  @raw_data
end

Class Method Details

.from_data(channel_data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
12
13
14
15
16
17
# File 'lib/lita/adapters/slack/slack_channel.rb', line 9

def from_data(channel_data)
  new(
      channel_data['id'],
      channel_data['name'],
      channel_data['created'],
      channel_data['creator'],
      channel_data
  )
end

.from_data_array(channels_data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


20
21
22
# File 'lib/lita/adapters/slack/slack_channel.rb', line 20

def from_data_array(channels_data)
  channels_data.map { |channel_data| from_data(channel_data) }
end