Class: ChatSDK::PostableMessage
- Inherits:
-
Object
- Object
- ChatSDK::PostableMessage
- Defined in:
- lib/chat_sdk/postable_message.rb
Instance Attribute Summary collapse
-
#attachments ⇒ Object
readonly
Returns the value of attribute attachments.
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Class Method Summary collapse
Instance Method Summary collapse
- #card? ⇒ Boolean
-
#initialize(text: nil, card: nil, attachments: [], metadata: {}) ⇒ PostableMessage
constructor
A new instance of PostableMessage.
Constructor Details
#initialize(text: nil, card: nil, attachments: [], metadata: {}) ⇒ PostableMessage
Returns a new instance of PostableMessage.
7 8 9 10 11 12 13 |
# File 'lib/chat_sdk/postable_message.rb', line 7 def initialize(text: nil, card: nil, attachments: [], metadata: {}) raise ArgumentError, "text or card required" if text.nil? && card.nil? @text = text @card = card @attachments = @metadata = end |
Instance Attribute Details
#attachments ⇒ Object (readonly)
Returns the value of attribute attachments.
5 6 7 |
# File 'lib/chat_sdk/postable_message.rb', line 5 def @attachments end |
#card ⇒ Object (readonly)
Returns the value of attribute card.
5 6 7 |
# File 'lib/chat_sdk/postable_message.rb', line 5 def card @card end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/chat_sdk/postable_message.rb', line 5 def @metadata end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'lib/chat_sdk/postable_message.rb', line 5 def text @text end |
Class Method Details
.from(content) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/chat_sdk/postable_message.rb', line 19 def self.from(content) case content when PostableMessage then content when String then new(text: content) when Cards::Node then new(card: content, text: content.fallback_text) else raise ArgumentError, "cannot convert #{content.class} to PostableMessage" end end |
Instance Method Details
#card? ⇒ Boolean
15 16 17 |
# File 'lib/chat_sdk/postable_message.rb', line 15 def card? !@card.nil? end |