Class: Slack::BlockKit::CompositionObjects::Text
- Inherits:
-
Object
- Object
- Slack::BlockKit::CompositionObjects::Text
- Defined in:
- lib/slack/block_kit/composition_objects/text.rb
Constant Summary collapse
- PLAINTEXT =
:plain_text
- MRKDWN =
:mrkdwn
- NEWLINE =
"\n"
Instance Attribute Summary collapse
-
#emoji ⇒ Object
readonly
Returns the value of attribute emoji.
-
#text ⇒ Object
Returns the value of attribute text.
-
#type ⇒ Object
Returns the value of attribute type.
-
#verbatim ⇒ Object
readonly
Returns the value of attribute verbatim.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#emoji ⇒ Object (readonly)
Returns the value of attribute emoji.
8 9 10 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 8 def emoji @emoji end |
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 8 def text @text end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 8 def type @type end |
#verbatim ⇒ Object (readonly)
Returns the value of attribute verbatim.
8 9 10 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 8 def verbatim @verbatim end |
Class Method Details
.[](hash) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 14 def self.[](hash) new.tap do |object| object.type = hash.keys.find { |key| [PLAINTEXT, MRKDWN].include?(key) } raise ArgumentError, 'type must be `plain_text` or `mrkdwn`' unless object.type object.text = hash[object.type] object.emoji! if hash[:emoji] object.verbatim! if hash[:verbatim] end end |
Instance Method Details
#emoji! ⇒ Object
29 30 31 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 29 def emoji! @emoji = true end |
#empty? ⇒ Boolean
25 26 27 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 25 def empty? text&.empty? end |
#to_h ⇒ Object
52 53 54 55 56 57 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 52 def to_h { type: type, text: text, emoji: emoji, verbatim: verbatim }.compact end |
#verbatim! ⇒ Object
33 34 35 |
# File 'lib/slack/block_kit/composition_objects/text.rb', line 33 def verbatim! @verbatim = true end |