class Stride::BotMention

Attributes

json[RW]

Public Class Methods

new(json) click to toggle source
# File lib/stride/bot_mention.rb, line 3
def initialize(json)
  self.json = json
end

Public Instance Methods

conversation() click to toggle source
# File lib/stride/bot_mention.rb, line 23
def conversation
  Conversation.new(json['conversation'])
end
mentions() click to toggle source
# File lib/stride/bot_mention.rb, line 15
def mentions
  content_blocks.select(&:mention?)
end
sender_id() click to toggle source
# File lib/stride/bot_mention.rb, line 19
def sender_id
  json['sender']['id']
end
text() click to toggle source
# File lib/stride/bot_mention.rb, line 7
def text
  json['message']['text']
end
text_with_mentions_as_user_ids() click to toggle source
# File lib/stride/bot_mention.rb, line 27
def text_with_mentions_as_user_ids
  content_blocks.map { |block| block.respond_to?(:at_id) ? block.at_id : block.text }.join.strip
end
text_without_mentions() click to toggle source
# File lib/stride/bot_mention.rb, line 11
def text_without_mentions
  content_blocks.select(&:text?).map(&:text).join.strip
end

Private Instance Methods

content_blocks() click to toggle source
# File lib/stride/bot_mention.rb, line 35
def content_blocks
  ContentBlock.wrap(content_json)
end
content_json() click to toggle source
# File lib/stride/bot_mention.rb, line 39
def content_json
  content = json['message']['body']['content']
  content.detect { |json| json['type'] == 'paragraph' } || content.first
end