Class: Slack::BlockKit::Layout::RichText::RichTextElements::Link
- Inherits:
-
Object
- Object
- Slack::BlockKit::Layout::RichText::RichTextElements::Link
- Includes:
- StyleHelper
- Defined in:
- lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb
Overview
Constant Summary collapse
- TYPE =
'link'
- VALID_STYLES =
%w[bold italic strike code].freeze
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(url:, text: nil, unsafe: nil, styles: []) ⇒ Link
constructor
A new instance of Link.
Methods included from StyleHelper
#styles_as_json, #validate_styles
Constructor Details
#initialize(url:, text: nil, unsafe: nil, styles: []) ⇒ Link
Returns a new instance of Link.
14 15 16 17 18 19 20 |
# File 'lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb', line 14 def initialize(url:, text: nil, unsafe: nil, styles: []) @url = url @text = text @unsafe = unsafe @styles = styles validate_styles(styles, VALID_STYLES) end |
Instance Method Details
#as_json ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/slack/block_kit/layout/rich_text/rich_text_elements/link.rb', line 22 def as_json(*) { type: TYPE, url: @url, text: @text, unsafe: @unsafe, style: styles_as_json(@styles) }.compact end |