Class: MsTeamsHermes::MsTeams::Entities::Mention
- Defined in:
- lib/msteams_hermes/msteams/entities/mention.rb
Overview
A class representing Microsoft’s Msteams.Mention object learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-format?tabs=adaptive-md%2Cdesktop%2Cconnector-html#user-mention-in-incoming-webhook-with-adaptive-cards
Instance Attribute Summary collapse
-
#mention_reference ⇒ Object
readonly
Returns the value of attribute mention_reference.
-
#mention_string ⇒ Object
readonly
Returns the value of attribute mention_string.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
-
#initialize(text:, name:, id:) ⇒ Mention
constructor
A new instance of Mention.
- #to_hash ⇒ Object
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_reference ⇒ Object (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_string ⇒ Object (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_id ⇒ Object (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_hash ⇒ Object
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 |