Class: Bot::Message::Card

Inherits:
Base
  • Object
show all
Defined in:
lib/bot/messages/card.rb

Instance Attribute Summary

Attributes inherited from Base

#message

Instance Method Summary collapse

Methods inherited from Base

#as_json, #method_missing

Constructor Details

#initialize(to, url, text, suggested_responses = false, options = {}) ⇒ Card

Returns a new instance of Card.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bot/messages/card.rb', line 4

def initialize(to, url, text, suggested_responses=false, options={})
  icon = options.delete("icon")

  self.message = {
    'type' => 'link',
    'to' => to,
    'url' => url,
    'title' => "", # Displays over the image
    'text' => text, # Displays under the image
    'attribution' => {
        'name' => text # Displays in bottom line
    },
  }.merge(options)

  self.message['picUrl'] = icon if icon
  self.message['attribution']['iconUrl'] = icon if icon

  self.message['chatId'] = options['chatId'] if options['chatId']
  self.suggested_responses = suggested_responses
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bot::Message::Base