Class: Lita::Adapters::Slack::SlackUser

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

Overview

A struct representing a Slack user.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, real_name, metadata) ⇒ SlackUser

Returns a new instance of SlackUser.



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

def initialize(id, name, real_name, )
  @id = id
  @name = name
  @real_name = real_name.to_s
  @email = ['email'].to_s
  @metadata = 
end

Instance Attribute Details

#emailString (readonly)

Returns The user’s email address, e.g. [email protected].

Returns:



31
32
33
# File 'lib/lita/adapters/slack/slack_user.rb', line 31

def email
  @email
end

#idString (readonly)

Returns The user’s unique ID.

Returns:

  • (String)

    The user’s unique ID.



25
26
27
# File 'lib/lita/adapters/slack/slack_user.rb', line 25

def id
  @id
end

#metadataHash (readonly) Also known as: raw_data

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

Returns:

  • (Hash)

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



33
34
35
# File 'lib/lita/adapters/slack/slack_user.rb', line 33

def 
  @metadata
end

#nameString (readonly)

Returns The user’s mention name, e.g. @alice.

Returns:

  • (String)

    The user’s mention name, e.g. @alice.



27
28
29
# File 'lib/lita/adapters/slack/slack_user.rb', line 27

def name
  @name
end

#real_nameString (readonly)

Returns The user’s display name, e.g. Alice Bobhart.

Returns:

  • (String)

    The user’s display name, e.g. Alice Bobhart



29
30
31
# File 'lib/lita/adapters/slack/slack_user.rb', line 29

def real_name
  @real_name
end

Class Method Details

.from_data(user_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
# File 'lib/lita/adapters/slack/slack_user.rb', line 9

def from_data(user_data)
  new(
    user_data['id'],
    user_data['name'],
    user_data['real_name'],
    user_data
  )
end

.from_data_array(users_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.



19
20
21
# File 'lib/lita/adapters/slack/slack_user.rb', line 19

def from_data_array(users_data)
  users_data.map { |user_data| from_data(user_data) }
end