Class: MsTeamsHermes::MsTeams::Entities::Mention

Inherits:
Base
  • Object
show all
Defined in:
lib/msteams_hermes/msteams/entities/mention.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, name:, id:) ⇒ Mention

Returns a new instance of Mention.



15
16
17
18
19
20
21
22
23
# File 'lib/msteams_hermes/msteams/entities/mention.rb', line 15

def initialize(text:, name:, id:)
  raise "`text` must be a string" unless text.is_a? String
  raise "`text` must contain <at>...</at>" unless text.include?("<at>") && text.include?("</at>")
  raise "`id` must be a string" unless text.is_a? String

  @mention_reference = text # String surrounded by <at>string</at> that marks the mention section in a text
  @mention_string = name # allows for overriding the mention_reference
  @user_id = id
end

Instance Attribute Details

#mention_referenceObject (readonly)

Returns the value of attribute mention_reference.



13
14
15
# File 'lib/msteams_hermes/msteams/entities/mention.rb', line 13

def mention_reference
  @mention_reference
end

#mention_stringObject (readonly)

Returns the value of attribute mention_string.



13
14
15
# File 'lib/msteams_hermes/msteams/entities/mention.rb', line 13

def mention_string
  @mention_string
end

#user_idObject (readonly)

Returns the value of attribute user_id.



13
14
15
# File 'lib/msteams_hermes/msteams/entities/mention.rb', line 13

def user_id
  @user_id
end

Instance Method Details

#to_hashObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/msteams_hermes/msteams/entities/mention.rb', line 25

def to_hash
  {
    type: "mention",
    text: mention_reference,
    mentioned: {
      id: user_id,
      name: mention_string
    }
  }
end